Changeset

8610:b03c7884fade

util.async: You can never have too many asserts!
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Mar 2018 22:30:25 +0000
parents 8609:9f6ab206d741
children 8611:937de0c39279
files util/async.lua
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/async.lua	Fri Mar 16 22:26:15 2018 +0000
+++ b/util/async.lua	Fri Mar 16 22:30:25 2018 +0000
@@ -23,6 +23,8 @@
 		local level = 0;
 		while debug.getinfo(thread, level, "") do level = level + 1; end
 		ok, runner = debug.getlocal(thread, level-1, 1);
+		assert(ok == "self", "unexpected async state: variable mismatch");
+		assert(runner.thread == thread, "unexpected async state: thread mismatch");
 		local error_handler = runner.watchers.error;
 		if error_handler then error_handler(runner, debug.traceback(thread, err)); end
 		local ready_handler = runner.watchers.ready;