diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-05-16 16:34:47 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-05-16 16:34:47 +0000 |
commit | a63358d02ae15ff9a62961d46e58bff26dbab68c (patch) | |
tree | 31361a3dbfdd678535374f9b38a03408bb86151e /operators.c | |
parent | d78b13ae6bbf408a102108228932aad9fdd6c930 (diff) |
Implement selective receive
Diffstat (limited to 'operators.c')
-rw-r--r-- | operators.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/operators.c b/operators.c index 36dcd6a..5359a54 100644 --- a/operators.c +++ b/operators.c @@ -155,13 +155,13 @@ opSelfReference1(Datum *lefto, Array *left, Array *right) Array * opReceive(Datum *lefto, Array *left, Array *right) { + USED(left); if(lefto->tag != FunctionTag) throwerror(nil, ESyntax); if(GetType(right) != AtypeInt && GetType(right) != AtypeFloat) throwerror(nil, EDomain); if(GetSize(right) != 1 && GetSize(right) != 0) throwerror(nil, ELength); - USED(left); int timeout = 0; if(GetSize(right) == 0) @@ -170,6 +170,9 @@ opReceive(Datum *lefto, Array *left, Array *right) timeout = right->intdata[0]*1000; else if(GetType(right) == AtypeFloat) timeout = right->floatdata[0]*1000; + if(GetSize(right) == 1 && timeout < 0) + throwerror(L"Timeout must be non-negative", EDomain); + return messagerecv(lefto->func, timeout); } |