Hubbry Logo
search
logo

Join-pattern

logo
Community Hub0 Subscribers
Write something...
Be the first to start a discussion here.
Be the first to start a discussion here.
See all
Join-pattern

Join-patterns provides a way to write concurrent, parallel and distributed computer programs by message passing. Compared to the use of threads and locks, this is a high level programming model using communication constructs model to abstract the complexity of concurrent environment and to allow scalability. Its focus is on the execution of a chord between messages atomically consumed from a group of channels.

This template is based on join-calculus and uses pattern matching. Concretely, this is done by allowing the join definition of several functions and/or channels by matching concurrent call and messages patterns. It is a type of concurrency pattern because it makes easier and more flexible for these entities to communicate and deal with the multi-threaded programming paradigm.

The join-pattern (or a chord in ) is like a super pipeline with synchronisation and matching. In fact, this concept is summarise by match and join a set of message available from different message queues, then handles them all simultaneously with one handler. It could be represented by the keywords when to specify the first communication that we expected, with the and to join/pair other channels and the do to run some tasks with the different collected messages. A constructed join pattern typically takes this form:

Argument a1 of When(a1) may be a synchronous or asynchronous channel or an array of asynchronous channels. Each subsequent argument ai to And(ai) (for i > 1) must be an asynchronous channel.

More precisely, when a message matches with a chain of linked patterns causes its handler to run (in a new thread if it's in asynchronous context) otherwise the message is queued until one of its patterns is enabled; if there are several matches, an unspecified pattern is selected.

Unlike an event handler, which services one of several alternative events at a time, in conjunction with all other handlers on that event, a join pattern waits for a conjunction of channels and competes for execution with any other enabled pattern.

Join-pattern is defined by a set of pi-calculus channels x that supports two different operations, sending and receiving, we need two join calculus names to implement it: a channel name x for sending (a message), and a function name x for receiving a value (a request). The meaning of the join definition is that a call to x() returns a value that was sent on a channel x<>. Each time functions are concurrently, triggers the return process and synchronizes with other joins.

From a client’s perspective, a channel just declares a method of the same name and signature. The client posts a message or issues a request by invoking the channel as a method. A continuation method must wait until/unless a single request or message has arrived on each of the channels following the continuation’s When clause. If the continuation gets to run, the arguments of each channel invocation are dequeued (thus consumed) and transferred (atomically) to the continuation’s parameters.

See all
User Avatar
No comments yet.