Giter Club home page Giter Club logo

session-csharp's Introduction

SessionC#

Session-typed concurrent and distributed programming for .NET

Fluent Session Programming in C# (PLACES 2020) [Paper] - Shunsuke Kimura, Keigo Imai

We propose SessionC#, a lightweight session typed library for safe concurrent/distributed programming. The key features are (1) the improved fluent interface which enables writing communication in chained method calls, by exploiting C#'s out variables, and (2) amalgamation of session delegation with async/await, which materialises session cancellation in a limited form, which we call session intervention. We show the effectiveness of our proposal via a Bitcoin miner application.

Code

The lightweight version, which includes only types, protocol combinators, and the endpoint API is summarized based on the paper, is available in the SessionCSharpLight directory.

Requirements

Developed using the .NET SDK 8, supports a variety of operating systems, including Windows, macOS, and Linux.

Examples

Applications

Citation

@article{sessioncs,
   title={Fluent Session Programming in C#},
   volume={314},
   ISSN={2075-2180},
   url={http://dx.doi.org/10.4204/EPTCS.314.6},
   DOI={10.4204/eptcs.314.6},
   journal={Electronic Proceedings in Theoretical Computer Science},
   publisher={Open Publishing Association},
   author={Kimura, Shunsuke and Imai, Keigo},
   year={2020},
   month=apr, pages={61–75}
}

session-csharp's People

Contributors

curegit avatar keigoi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

keigoi

session-csharp's Issues

非継続渡しの消極的選択メソッド

非継続渡しの消極的選択メソッドを実装したい。

分岐先を表すコンストラクタと分岐先のセッションをもつバリアントを用意するのが理想。

Choice <a, b> = Left of a | Right of b

コンスタントをinternalにした抽象クラスを用いると、派生クラスの作成を制限できる。
バリアントの代わりとなる。

namespace SessionTypes.Binary
{
	public abstract class Choice<L, R> where L : SessionType where R : SessionType
	{
		internal Choice() { }
	}

	public sealed class Left<L, R> : Choice<L, R> where L : SessionType where R : SessionType
	{
	}

	public sealed class Right<L, R> : Choice<L, R> where L : SessionType where R : SessionType
	{
	}
}

しかしダウンキャストのために型をパラメータ含めて書く必要がある。

switch (c2.Follow())
{
	case Left<Respond<int, Close>, Respond<string, Close>> left:
		break;
	case Right<Respond<int, Close>, Respond<string, Close>> right:
		break;
}

非継続渡しの消極的選択メソッドとFluent APIをあわせると、名前変えを抑えつつ手続き的な制御構造と親和に書けるので、需要は大きい。
もっと思考を要する。

Fluent API補助メソッド

Session Continue((Session, Value) session, out T value)
のような拡張メソッドを用意すると
(await s.Send(v).Receive()).Continue(out var value).Send(...)
非同期受信をこのようにチェーンできる

Session Let(Session session, out T var, T value)
のような拡張メソッドを用意すると
s.Receive(out var v).Let(out var r, Sqrt(v)).Send(r).Send(Sqrt(r)).Close()
チェーンの途中で変数宣言ができる

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.