All Projects → chrisa23 → Fibrous

chrisa23 / Fibrous

Licence: MIT license
Concurrency library for .Net

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Fibrous

wasmcloud-otp
wasmCloud host runtime that leverages Elixir/OTP and Rust to provide simple, secure, distributed application development using the actor model
Stars: ✭ 197 (+319.15%)
Mutual labels:  actors
Octavo
Verilog FPGA Parts Library. Old Octavo soft-CPU project.
Stars: ✭ 66 (+40.43%)
Mutual labels:  multi-threading
table2pojo
Generate POJOs for database table/columns
Stars: ✭ 16 (-65.96%)
Mutual labels:  multi-threading
foxpages
Visual FoxPro Multithread Web Server
Stars: ✭ 22 (-53.19%)
Mutual labels:  multi-threading
Akka.Persistence.MongoDB
MongoDB support for Akka.Persistence
Stars: ✭ 30 (-36.17%)
Mutual labels:  actors
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+2119.15%)
Mutual labels:  multi-threading
Aff3ct
A fast simulator and a library dedicated to the channel coding.
Stars: ✭ 240 (+410.64%)
Mutual labels:  multi-threading
cucumber-performance
A performance testing framework for cucumber
Stars: ✭ 28 (-40.43%)
Mutual labels:  multi-threading
android-downloader
An powerful download library for Android.
Stars: ✭ 375 (+697.87%)
Mutual labels:  multi-threading
protoactor-python
Proto Actor - Ultra fast distributed actors
Stars: ✭ 78 (+65.96%)
Mutual labels:  actors
Actors.jl
Concurrent computing in Julia based on the Actor Model
Stars: ✭ 95 (+102.13%)
Mutual labels:  actors
endless
Scala library to describe sharded and event sourced entities using tagless-final algebras
Stars: ✭ 70 (+48.94%)
Mutual labels:  actors
Master-Thesis
Deep Reinforcement Learning in Autonomous Driving: the A3C algorithm used to make a car learn to drive in TORCS; Python 3.5, Tensorflow, tensorboard, numpy, gym-torcs, ubuntu, latex
Stars: ✭ 33 (-29.79%)
Mutual labels:  multi-threading
meio
Rust actors alternative to Erlang/OTP
Stars: ✭ 152 (+223.4%)
Mutual labels:  actors
akka-contextual-actor
A really small library (just a few classes) which lets you trace your actors messages transparently propagating a common context together with your messages and adding the specified values to the MDC of the underlying logging framework.
Stars: ✭ 17 (-63.83%)
Mutual labels:  actors
super-workers
🐴 Distribute load on front-end via parallelism
Stars: ✭ 93 (+97.87%)
Mutual labels:  multi-threading
SOMns
SOMns: A Newspeak for Concurrency Research
Stars: ✭ 62 (+31.91%)
Mutual labels:  actors
superfast
⚡ SuperFast codecs for fre:ac
Stars: ✭ 59 (+25.53%)
Mutual labels:  multi-threading
effpi
Verified message-passing programs in Dotty
Stars: ✭ 42 (-10.64%)
Mutual labels:  actors
xsystem
Building Blocks for XState-based Actor Systems.
Stars: ✭ 40 (-14.89%)
Mutual labels:  actors

Banner

Fibrous

NuGet

High performance concurrency library for the .Net platform. Fibrous is a fork of Retlang [http://code.google.com/p/retlang/].

Fibrous is an actor-like framework but more of a flexible set of concurrency components. The main abstractions are Fibers, Ports and Channels. Fibers are execution contexts, Ports are messaging end points, and channels are combinations of ports that allow decoupling of fiber components.

Some of the library benefits:

  • Tiny library that makes multi-threading simple and easy to reason about
  • Thread safe publishing
  • Single or multiple subscribers
  • Request reply
  • UI fibers for worry free UI marshalling
  • Batching support
  • Scheduling support (Cron, DateTime and TimeSpan based)

Fibrous is great for multi-threading when you don't need extreme low latency or distributed actors but want an easy to reason about and extremely flexible messaging based model. Fibrous is also fast. It's in production use in multiple trading systems, both server side and front end.

If you need distributed concurrency, look into Akka.net or Proto.Actor and if you need extreme performance and super low latency, look into Disruptor.net.

Fibers

Fibers are synchronous execution contexts that maintain order of actions. Like Actors, Fibers can manage state without worries of cross threading issues. While a Fiber is synchronous, your system can consist of multiple Fibers communicating through messaging to provide parallelism to your system.

In version 3, Async Fibers were introduced. These work off of Func<Task> rather than Action delegates allowing a fiber based component to use async/await safely.

Fibers subscribe to channels to receive messages which queue actions based on the assigned handler. Fibers have a scheduling API that allows actions to be scheduled in the future as well as repeatedly. You can also directly queue actions onto a Fiber for it to execute.

Fibers are a repository of IDisposable objects and will dispose of all children upon the Fibers disposal. This is used to clean up subscriptions and scheduling for any fiber. This is also useful for dealing with children used in the Fiber's context that implement IDisposable.

There are specialised Fibers for Windows Forms and WPF, which automatically handle invoking actions on the UI/Dispatcher thread. There is a StubFiber, which is used for testing and special cases, and immediately executes actions on the calling thread.

//Representations of the IFiber and IAsyncFiber interface.
//There are many extensions to enable more complex behavior
public interface IFiber : IDisposable
{
    void Enqueue(Action action);
    IDisposable Schedule(Action action, TimeSpan dueTime);
    IDisposable Schedule(Action action, TimeSpan startTime, TimeSpan interval);
    void Add(IDisposable toAdd);
    void Remove(IDisposable toRemove);
}

public interface IAsyncFiber : IDisposable
{
    void Enqueue(Func<Task> action);
    IDisposable Schedule(Func<Task> action, TimeSpan dueTime);
    IDisposable Schedule(Func<Task> action, TimeSpan startTime, TimeSpan interval);
    void Add(IDisposable toAdd);
    void Remove(IDisposable toRemove);
}
//Work is done on the thread pool, but in a sequential fashion 
IFiber fiber = new Fiber();  
	 
//You can enqueue methods
fiber.Enqueue(SomeParameterlessMethod);
 
//or lambdas
fiber.Enqueue(() => DoSomeWork(someParam));

//You can schedule when things happen
fiber.Schedule(ScheduledMethod, when);

//and also have them repeat
fiber.Schedule(ScheduledMethod, startWhen, repeatInterval);

Ports and Channels

Ports are the end points for publishing and subscribing to messages.

The port types (ISubscriberPort, IPublisherPort, IRequestPort<TRequest, TReply>, ISnapshotSubscriberPort<T, TSnapshot>, IEventPort and IEventTrigger) allow a variety of behavior around message passing and events.

Channels are the conduit for message passing between Fibers, and allow decoupling of the parts of your system. There are a variety of channel types built into Fibrous: one way channels that notify all subscribers, request/reply, queue channels that give messages to one of multiple subscribers, as well as a state channel that acts like a last value cache.

There is a static EventBus which allows a simpler mechanism for passing messages when only one normal channel per type is needed and an EventHub that allows auto-wiring of handlers.

There are a variety of subscription methods, including filtered, batched, keyed batched and the last message after a time interval.

Examples:

IFiber fiber = new Fiber();  
	 
//Create a channel and subscribe to messages
IChannel<string> channel = new Channel<string>();

channel.Subscribe(fiber, s => Console.WriteLine(s.ToUpper()));

//You can also create a channel and subscribe in one line
IChannel<string> channel = fiber.NewChannel<string>(s => Console.WriteLine(s.ToUpper()));

//Publish a message to the channel
channel.Publish("the message");

//EventBus... Global static channel per type (string is only used as an example)
EventBus<string>.Subscribe(fiber, s => Console.WriteLine(s.ToUpper()));

EventBus<string>.Publish("the message");


//Agents make some things even simpler
var agent = new Agent<string>(s => Console.WriteLine(s.ToUpper()));
agent.Publish("the message");

Extras

A separate Fibrous.Extras library provides simple Actors, an IObserver wrapper, subscribable collections and composable pipelines

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].