diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-03-06 08:41:45 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-03-06 08:41:45 -0800 |
commit | db7fd08e05dc62497bf836c9ff781d91ee2b1c8b (patch) | |
tree | 58010741fadcfc801f73cde6b78270de7a343868 /src | |
parent | 8584e15b68c145c3c7a4511b917d9f6b3d20294c (diff) | |
download | teliva-db7fd08e05dc62497bf836c9ff781d91ee2b1c8b.tar.gz |
extract a helper
I'm starting to get quite indisciplined about where I introduce global bindings. Seems reasonable since any modules in Teliva will come from within the framework.
Diffstat (limited to 'src')
-rw-r--r-- | src/task.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/task.lua b/src/task.lua index dbe788f..54d6bb1 100644 --- a/src/task.lua +++ b/src/task.lua @@ -261,6 +261,10 @@ local function altexec(a) end end +function ischannel(x) + return type(x) == "table" and x.__index == _M.Channel +end + -- The main entry point. Call it `alt` or `select` or just a -- multiplexing statement. This is user facing function so make sure -- the parameters passed are sane. @@ -275,7 +279,7 @@ local function chanalt(alt_array, canblock) assert(type(a.op) == "number" and (a.op == RECV or a.op == SEND or a.op == NOP), "op field must be RECV, SEND or NOP in alt") - assert(type(a.c) == "table" and a.c.__index == _M.Channel, + assert(ischannel(a.c), "pass valid channel to a c field of alt") if altcanexec(a) == true then table.insert(list_of_canexec_i, i) |