Table of Contents

Class Sip

Namespace
MarymoorStudios.Core.Promises
Assembly
MarymoorStudios.Core.Promises.dll

A Software Isolated Process (SIP).

public sealed class Sip : IDisposable
Inheritance
Sip
Implements
Inherited Members

Remarks

A Software Isolated Process (SIP) is a single-threaded container that logically encapsulates a collection of concurrent (but not parallel) activities. A SIP may only execute on a single thread at a time, but at certain points (aka top-of-turn) it can be moved between threads (as all program state is known to be in the heap).

Being single-threaded, all computation within a SIP does not need locks, and is free from race conditions.

Computations running within a SIP can communicate with other SIP, either in the same process, in another process on the same machine, or on another machine, by using non-blocking Remote Procedure Calls (such as through Promise-based RPC).

Once created, a SIP can be run until either:

  1. The completion of a root computation (e.g. an AsyncMain function).
  2. The SIP's progress is blocked on IO (including timers).

Constructors

Sip()

Constructs a new SIP.

public Sip()

Methods

CreateAndRun(Func<Promise>)

Create a sip, run it to completion on the current thread, and then dispose it.

public static void CreateAndRun(Func<Promise> asyncMain)

Parameters

asyncMain Func<Promise>

The root computation. See Run(Func<Promise>)

CreateAndRun<TArgs>(TArgs, Func<TArgs, Promise>)

Create a sip, run it to completion on the current thread, and then dispose it.

public static void CreateAndRun<TArgs>(TArgs args, Func<TArgs, Promise> asyncMain)

Parameters

args TArgs

The arguments to the root computation.

asyncMain Func<TArgs, Promise>

The root computation. See Run(Func<Promise>)

Type Parameters

TArgs

CreateAndRun<TArgs, TReturn>(TArgs, Func<TArgs, Promise<TReturn>>)

Create a sip, run it to completion on the current thread, and then dispose it.

public static TReturn CreateAndRun<TArgs, TReturn>(TArgs args, Func<TArgs, Promise<TReturn>> asyncMain)

Parameters

args TArgs

The arguments to the root computation.

asyncMain Func<TArgs, Promise<TReturn>>

The root computation. See Run(Func<Promise>)

Returns

TReturn

Type Parameters

TArgs
TReturn

Dispose()

public void Dispose()

Run(Func<Promise>)

Run until the root computation asyncMain has completed.

public void Run(Func<Promise> asyncMain)

Parameters

asyncMain Func<Promise>

The root computation.

Remarks

All computation within the SIP should be rolled up hierarchically into the return value of asyncMain.

Run<TArgs>(TArgs, Func<TArgs, Promise>)

Run until the root computation asyncMain has completed.

public void Run<TArgs>(TArgs args, Func<TArgs, Promise> asyncMain)

Parameters

args TArgs

The arguments to the root computation.

asyncMain Func<TArgs, Promise>

The root computation.

Type Parameters

TArgs

Remarks

All computation within the SIP should be rolled up hierarchically into the return value of asyncMain.

Run<TArgs, TReturn>(TArgs, Func<TArgs, Promise<TReturn>>)

Run until the root computation asyncMain has completed.

public TReturn Run<TArgs, TReturn>(TArgs args, Func<TArgs, Promise<TReturn>> asyncMain)

Parameters

args TArgs

The arguments to the root computation.

asyncMain Func<TArgs, Promise<TReturn>>

The root computation.

Returns

TReturn

Type Parameters

TArgs
TReturn

Remarks

All computation within the SIP should be rolled up hierarchically into the return value of asyncMain.