View source code
Display the source code in std/concurrency.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.concurrency.receiveTimeout

Receives a message from another thread and gives up if no match arrives within a specified duration.

bool receiveTimeout(T...) (
  Duration duration,
  T ops
);

Receive a message from another thread, or block until duration exceeds, if no messages of the specified types are available. This function works by pattern matching a message against a set of delegates and executing the first match found.

If a delegate that accepts a Variant is included as the last argument, it will match any message that was not matched by an earlier delegate. If more than one argument is sent, the Variant will contain a Tuple of all values sent.

Parameters

NameDescription
duration Duration, how long to wait. If duration is negative, won't wait at all.
ops Variadic list of function pointers and delegates. Entries in this list must not occlude later entries.

Returns

true if it received a message and false if it timed out waiting for one.

Throws

OwnerTerminated when the sending thread was terminated.

Authors

Sean Kelly, Alex Rønne Petersen, Martin Nowak

License

Boost License 1.0.