GithubHelp home page GithubHelp logo

mcai4gl2 / busterwood.channels Goto Github PK

View Code? Open in Web Editor NEW

This project forked from busterwood/channels

0.0 2.0 0.0 34 KB

CSP-like channels for .NET 4.6

License: Apache License 2.0

C# 96.86% PowerShell 3.14%

busterwood.channels's Introduction

BusterWood.Channels

Build status

CSP-like channels for .NET 4.6 or above and .NET Core.

As its name suggests, CSP allows the description of systems in terms of component processes that operate independently, and interact with each other solely through message-passing communication.

Channel<T> class

The Channel<T>class is used for sending and receiving values between threads (or logical async threads) and has the following methods:

  • T Receive() reads a value from the channel, blocking until a sender has sent a value.
  • Task<T> ReceiveAsync() reads a value from the channel, the returned task will only complete when a sender has written the value to the channel.
  • bool TryReceive(out T) attempts to read a value from the channel, returns FALSE is no sender is ready.
  • void Send(T) writes a value to the channel, blocking until a receiver has got the value.
  • Task SendAsync(T) writes a value to the channel, the returned task will only complete when a receiver has got the value.
  • bool TrySend(T) attempts to write a value to the channel, returns FALSE is no receiver is ready.
  • void Close() prevents any further attempts to send to the channel
  • bool IsClosed has the channel been closed?

Select class

The Select class is used for reading from one of many possible channels, has the following methods:

  • Select OnReceive<T>(Channel<T>, Action<T>) builder method that adds an case to the select that executes a (synchronous) action when the channel is read.
  • Select OnReceiveAsync<T>(Channel<T>, Func<T, Task>) builder method that adds an case to the select that executes an asynchronous action when the channel is read.
  • Task ExecuteAsync() reads from one (and only one) of the channels and executes the associated action.

busterwood.channels's People

Contributors

busterwood avatar mcai4gl2 avatar

Watchers

 avatar  avatar

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.