www.digitalmars.com

D Programming Language 2.0

Last update Sun Jun 13 09:38:33 2010

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

class MessageMismatch: object.Exception;

class OwnerTerminated: object.Exception;

struct Tid;
An opaque type used to represent a logical local process.

Tid thisTid();
Returns the caller's Tid.

Tid spawn(T...)(void function(T) fn, T args);
Executes the supplied function in a new context represented by Tid.

Parameters:
fn The function to execute.
args Arguments to the function.

Returns:
A Tid representing the new context.

void send(T...)(Tid tid, T vals);
Sends the supplied value to the context represented by tid.

void receive(T...)(T ops);

receiveOnlyRet!(T) receiveOnly(T...)();

bool receiveTimeout(T...)(long ms, T ops);

enum OnCrowding;

block

throwException

ignore

void setMaxMailboxSize(Tid tid, size_t messages, OnCrowding doThis);

void setMaxMailboxSize(Tid tid, size_t messages, bool function(Tid) onCrowdingDoThis);