Diff

util/async.lua @ 8648:ca710a71d730

util.async: Add ready() to check whether running in async context
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Mar 2018 07:46:23 +0000
parent 8629:ddb04cacb8b1
child 8649:9246f64d6f1e
line wrap: on
line diff
--- a/util/async.lua	Wed Mar 21 17:03:13 2018 +0100
+++ b/util/async.lua	Thu Mar 22 07:46:23 2018 +0000
@@ -215,4 +215,8 @@
 	return log(level, "[runner %s] "..fmt, self.id, ...);
 end
 
-return { waiter = waiter, guarder = guarder, runner = runner };
+local function ready()
+	return pcall(checkthread);
+end
+
+return { ready = ready, waiter = waiter, guarder = guarder, runner = runner };