geod24.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 Tid, which allows messages to be sent to logical threads that are executing in both the current process and in external 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.

A logical thread is an execution context that has its own stack and which runs asynchronously to other logical threads. These may be preemptively scheduled kernel threads, fibers (cooperative user-space threads), or some other concept with similar behavior.

The type of concurrency used when logical threads are created is determined by the Scheduler selected at initialization time. The default behavior is currently to create a new kernel thread per call to spawn, but other schedulers are available that multiplex fibers across the main thread or use some combination of the two approaches.

Note: Copied (almost verbatim) from Phobos at commit 3bfccf4f1 (2019-11-27) Changes are this notice, and the module rename, from std.concurrency to geod24.concurrency.

Public Imports

std.variant
public import std.variant;
Undocumented in source.

Members

Classes

FiberScheduler
class FiberScheduler

An example Scheduler using Fibers.

InfoThread
class InfoThread

Thread with ThreadInfo, This is implemented to avoid using global variables.

MessageBox
class MessageBox
Undocumented in source.
MessageMismatch
class MessageMismatch

Thrown on calls to receiveOnly if a message other than the type the receiving thread expected is sent.

TidMissingException
class TidMissingException

Thrown when a Tid is missing, e.g. when ownerTid doesn't find an owner thread.

Functions

receive
void receive(Tid self, T ops)

Receives a message from another thread.

receiveOnly
receiveOnlyRet!(T) receiveOnly(Tid self)

Receives only messages with arguments of types T.

receiveTimeout
bool receiveTimeout(Tid self, Duration duration, T ops)

Tries to receive but will give up if no matches arrive within duration. Won't wait at all if provided core.time.Duration is negative.

send
void send(Tid tid, T vals)

Places the values as a message at the back of tid's message queue.

spawn
Tid spawn(F fn, T args)

Starts fn(args) in a new logical thread.

trySend
bool trySend(Tid tid, T vals)

Ditto, but do not assert in case of failure

Properties

thisTid
Tid thisTid [@property getter]

Structs

List
struct List(T)
ThreadInfo
struct ThreadInfo

Encapsulates all implementation-level data needed for scheduling.

Tid
struct Tid

An opaque type used to represent a logical thread.

Meta

License

<a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.

Authors

Sean Kelly, Alex Rønne Petersen, Martin Nowak