Joins (concurrency library)


Joins is an asynchronous concurrent computing API from Microsoft Research for the.NET Framework. It is based on join calculus and makes the concurrency constructs of the language available as a CLI assembly that any CLI compliant language can use.

Overview

Joins can be used to express concurrency in an application using the joins pattern, usable both for multi-threaded applications as well as for event based distributed applications. The Joins API emulates declarative type-safe expression of synchronization patterns.
The Joins library emulates asynchronous and synchronous methods. An asynchronous method, in Cω and Joins parlance, is one which does not block the caller method, nor does it return any result, whereas a synchronous method blocks the caller method. In the Joins API, synchronous as well as asynchronous methods are implemented as generic delegates. Usage of generics provide type safety. For example, a set of synchronous and asynchronous method can be created and using them to create an object that implements the pattern, as:

public class JoinDemo

When asynchronous methods are called, the parameters are put in a channel, which is a queue managed by the Joins runtime. The method can optionally start a new thread to process the parameters in the background, and return the results. When the corresponding synchronous method is called the parameter is returned for further processing. If no parameter is present in the queue when the synchronous method is called, the caller stalls. The Joins runtime schedules which parameter is returned based on whether it is ready.
The synchronization pattern of the methods are defined by joins patterns, which describes what happens when a set of channels are invoked. For example, what happens when Send and Retrieve are called together can be different than Send and Queue.

public void SetPatterns