Comparison

util/async.lua @ 8655:ba6a6a04b46c

util.async: Allow nil as a guard key
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Mar 2018 16:26:09 +0000
parent 8651:1b7c5933b215
child 8669:2aa85b0cd2b8
comparison
equal deleted inserted replaced
8654:425de10efde4 8655:ba6a6a04b46c
82 end; 82 end;
83 end 83 end
84 84
85 local function guarder() 85 local function guarder()
86 local guards = {}; 86 local guards = {};
87 local default_id = {};
87 return function (id, func) 88 return function (id, func)
89 id = id or default_id;
88 local thread = checkthread(); 90 local thread = checkthread();
89 local guard = guards[id]; 91 local guard = guards[id];
90 if not guard then 92 if not guard then
91 guard = {}; 93 guard = {};
92 guards[id] = guard; 94 guards[id] = guard;