The Core Libraries are a suite of C# tools offering a unique, easy to use, correct-by-construction, approach to race-free concurrent programming. Inspired by Midori, E-lang and Erlang, the Core is a Promise-based, single-threaded software-isolated process (Sip) model loosely conforming to Tony Hoarse's Communicating Sequential Processes (CSP) formalism.
byte arrays
, DateTime
, and unsigned
values).class
, struct
, record
, or record struct
types. [DataContract]
public abstract record GameEvent();
[DataContract]
public sealed record BuildCreate(PlayerToken Token, Vector2I Target) : GameEvent;
[DataContract]
public sealed record BuildDestroy(PlayerToken Token, Vector2I Target) : GameEvent;
Promise
/Promise<T>
as a drop-in replacement for Task
/Task<T>
.async
and await
keywords.Sequence<T>
provides efficient bulk transfer, subscriptions, and transformations.IAsyncObservable
-style event-driven programming with server-push support.Resolver<T>
supports ad-hoc as well as structured concurrency. int count = 0;
// Add-hoc resolution with first-class resolvers.
Resolver<Void> r1 = new();
// Promise-based computations and composition.
Promise p1 = new(r1);
Promise p2 = p1.When(() => count++);
// Promise chaining.
p2 = p2.When(() => count++);
// Explicit resolution.
r1.Resolve();
// Await for resolutions to settle.
await p1;
// Downstream propagation through the computational graph.
await p2;
// Functional data-flow
Promise<int> p3 = p1.When(() => Promise.From(count));
Assert.AreEqual(2, await p3);
Sequence<T>
. Allows bulk transfers, server push, object streaming (with flow control).Bytes
Stream. Allows efficient binary streaming (with flow control).Nullable<T>
parameter support.= default_value
attributions are copied to generated proxy[MaybeNullWhen]
.[Eventual]
public partial interface IGameLauncher
{
/// <summary>The game endpoint.</summary>
public Promise<IPEndPoint> GetEndpoint();
/// <summary>Returns the first game event whose timestamp is larger than <paramref name="previous"/>.</summary>
/// <param name="previous">The timestamp of the last game event seen by the caller.</param>
/// <returns>The game event along with its timestamp.</returns>
public Sequence<Timestamped<LauncherEvent>> GetNext(ulong previous);
/// <summary>Attempts to join the game as a player.</summary>
/// <param name="player">Which player slot to join as.</param>
/// <param name="name">The name.</param>
/// <param name="client">A proxy to the player's client.</param>
/// <returns>Resolves if successfully, broken otherwise.</returns>
public JoinedPlayerProxy TryJoin(PlayerToken player, string name, ClientLauncherProxy client);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////
[DataContract]
public abstract record LauncherEvent();
/// <summary>The last event indicating the launcher has launched.</summary>
[DataContract]
public sealed record LaunchedEvent() : LauncherEvent;
}
/// <summary>A capability to manage a joined player's slot subscription on an active launcher.</summary>
[Eventual]
public partial interface IJoinedPlayer
{
/// <summary>Removes the player from the game.</summary>
public Promise Leave();
}
Last modified 28 April 2025