From a63358d02ae15ff9a62961d46e58bff26dbab68c Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 16 May 2022 16:34:47 +0000 Subject: Implement selective receive --- operators.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'operators.c') 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); } -- cgit v1.2.3