std.concurrency
This is a low-level messaging API upon which more structured or restrictive APIs may be built. The general idea is that every messageable entity is represented by a common handle type (called a Cid in this implementation), which allows messages to be sent to in-process threads, on-host processes, and foreign-host processes using the same interface. This is an important aspect of scalability because it allows the components of a program to be spread across available resources with few to no changes to the actual implementation. Right now, only in-process threads are supported and referenced by a more specialized handle called a Tid. It is effectively a subclass of Cid, with additional features specific to in-process messaging. License:Boost License 1.0. Authors:
Sean Kelly Copyright Sean Kelly 2009 - 2010. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at ) http:
//www.boost.org/LICENSE_1_0.txt
- An opaque type used to represent a logical local process.
- Returns the caller's Tid.
- Executes the supplied function in a new context represented by Tid. The
calling context is designated as the owner of the new context. When the
owner context terminated an OwnerTerminated message will be sent to the
new context, causing an OwnerTerminated exception to be thrown on
receive().
Parameters:
Returns:fn The function to execute. args Arguments to the function.
A Tid representing the new context. - Executes the supplied function in a new context represented by Tid. This
new context is linked to the calling context so that if either it or the
calling context terminates a LinkTerminated message will be sent to the
other, causing a LinkTerminated exception to be thrown on receive(). The
owner relationship from spawn() is preserved as well, so if the link
between threads is broken, owner termination will still result in an
OwnerTerminated exception to be thrown on receive().
Parameters:
Returns:fn The function to execute. args Arguments to the function.
A Tid representing the new context. - Sends the supplied value to the context represented by tid.
- These behaviors may be specified when a mailbox is full.
- Wait until room is available.
- Throw a MailboxFull exception.
- Abort the send and return.
- Sets a limit on the maximum number of user messages allowed in the mailbox.
If this limit is reached, the caller attempting to add a new message will
execute the behavior specified by doThis. If messages is zero, the mailbox
is unbounded.
Parameters:
Tid tid The Tid of the thread for which this limit should be set. size_t messages The maximum number of messages or zero if no limit. OnCrowding doThis The behavior executed when a message is sent to a full mailbox. - Sets a limit on the maximum number of user messages allowed in the mailbox.
If this limit is reached, the caller attempting to add a new message will
execute onCrowdingDoThis. If messages is zero, the mailbox is unbounded.
Parameters:
Tid tid The Tid of the thread for which this limit should be set. size_t messages The maximum number of messages or zero if no limit. bool function(Tid) onCrowdingDoThis The routine called when a message is sent to a full mailbox.