All Projects → cschladetsch → Flow

cschladetsch / Flow

Licence: mit
C# co-routine Kernel for .Net. Includes Futures, Barriers, Triggers, Timers and Groups. Gamasutra article provides extra documentation.

Programming Languages

csharp
926 projects
flow
126 projects

Projects that are alternatives of or similar to Flow

Fiber Ext
stackful-coroutines for PHP
Stars: ✭ 142 (+140.68%)
Mutual labels:  coroutines, coroutine
Tascalate Javaflow
Continuations / CoRoutines for Java 1.5 - 11, build tools, CDI support. This project is based on completely re-worked Apache Jakarta Commons JavaFlow library.
Stars: ✭ 51 (-13.56%)
Mutual labels:  coroutines, coroutine
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (+142.37%)
Mutual labels:  coroutines, coroutine
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+3737.29%)
Mutual labels:  coroutine, coroutines
Coroutine
C++ 20 Coroutines in Action (Helpers + Test Code Examples)
Stars: ✭ 262 (+344.07%)
Mutual labels:  coroutines, coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (+177.97%)
Mutual labels:  coroutines, coroutine
Mvvmtemplate
An Android Template with MVVM and Clean Architecture
Stars: ✭ 182 (+208.47%)
Mutual labels:  coroutines, coroutine
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-66.1%)
Mutual labels:  coroutines, coroutine
DeezerClone
This Application using Dagger Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData),Navigation based on MVVM architecture.
Stars: ✭ 81 (+37.29%)
Mutual labels:  coroutines, coroutine
Jacob
A lightweight library to provide coroutines in Java
Stars: ✭ 14 (-76.27%)
Mutual labels:  coroutines, coroutine
Libfiber
The high performance coroutine library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iocp/windows GUI
Stars: ✭ 519 (+779.66%)
Mutual labels:  coroutines, coroutine
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+476.27%)
Mutual labels:  coroutines, coroutine
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+1069.49%)
Mutual labels:  coroutines, coroutine
Ktx
LibKTX: Kotlin extensions for LibGDX games and applications
Stars: ✭ 913 (+1447.46%)
Mutual labels:  coroutines
Mvi Cleanarch
simple code for MVI architecture
Stars: ✭ 45 (-23.73%)
Mutual labels:  coroutines
May
rust stackful coroutine library
Stars: ✭ 909 (+1440.68%)
Mutual labels:  coroutines
Saber
⚔️ Saber, PHP异步协程HTTP客户端 | PHP Coroutine HTTP client - Swoole Humanization Library
Stars: ✭ 866 (+1367.8%)
Mutual labels:  coroutine
Awesome Android Kotlin Apps
👓 A curated list of awesome android kotlin apps by open-source contributors.
Stars: ✭ 1,058 (+1693.22%)
Mutual labels:  coroutines
Mvvm Kotlin Android Architecture
MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit5
Stars: ✭ 1,014 (+1618.64%)
Mutual labels:  coroutines
Runtimepermission
Simpliest way to ask runtime permissions on Android, no need to extend class or override permissionResult method, choose your way : Kotlin / Coroutines / RxJava / Java7 / Java8
Stars: ✭ 860 (+1357.63%)
Mutual labels:  coroutines

Flow Foo

Build status CodeFactor License Release

A C# coroutine-based Kernel for .Net. If you are one of the many developers using this library, I encourage you provide any feedback and/or fork.

This is Unity-friendly and will work on all versions of Unity after 4.0. Please let me know otherwise.

Current documentation is at GamaSutra but the formatting is a bit screwy.

The original post was on AltDevBlogADay but that site is now lost for the ages.

Tests

The tests reside in TestFlow/Editor so they can be used from Unity3d as well.

These tests, along with the GamaSutra article, are the best first sources of documentation.

Example 1

Using Flow for async REST communications.

private void CreateHeartbeat()
{
    New.PeriodicTimer(TimeSpan.FromMinutes(2)).Elapsed += tr =>
    {
        Get<UserCount>("user/alive").Then(result =>
        {
            if (result.Succeeded(out var val))
            {
                _activeUsers.Value = val.Num;
                Info($"{val.Num} users online.");
            }
        });
    };
}

Example 2

This is example code pulled straight for a game I'm quasi-working on:

public void GameLoop()
{
    Root.Add(
        New.Sequence(
            New.Coroutine(StartGame).Named("StartGame"),
            New.While(() => !_gameOver),
                New.Coroutine(PlayerTurn).Named("Turn").Named("While"),
            New.Coroutine(EndGame).Named("EndGame")
        ).Named("GameLoop")
    );
}

Note the .Named("Name") extenstions to the factory methods: these are for debugging and tracing purposes. The library comes with extensive debugging and visualisation support, so you can see in real time as the kernel changes.

The main logic flow for starting a turn is:

private IEnumerator StartGame(IGenerator self)
{
    var start = New.Sequence(
        New.Barrier(
            WhitePlayer.StartGame(),
            BlackPlayer.StartGame()
        ).Named("Init Game"),
        New.Barrier(
            WhitePlayer.DrawInitialCards(),
            BlackPlayer.DrawInitialCards()
        ).Named("Deal Cards"),
        New.Barrier(
            New.TimedBarrier(
                TimeSpan.FromSeconds(Parameters.MulliganTimer),
                WhitePlayer.AcceptCards(),
                BlackPlayer.AcceptCards()
            ).Named("Mulligan"),
            New.Sequence(
                WhitePlayer.PlaceKing(),
                BlackPlayer.PlaceKing()
            ).Named("Place Kings")
        ).Named("Preceedings")
    ).Named("Start Game");
    start.Completed += (tr) => Info("StartGame completed");
    yield return start;
}

And the relevant IPlayerAgent Method declaractions as being:

ITimer StartGame();
ITimer DrawInitialCards();
ITimedFuture<bool> AcceptCards();
ITimedFuture<PlacePiece> PlaceKing();
ITransient ChangeMaxMana(int i);
ITimedFuture<ICardModel> DrawCard();
ITimedFuture<PlacePiece> PlayCard();
ITimedFuture<MovePiece> MovePiece();
ITimedFuture<Pass> Pass();

This is just a simple example on how the library is tyically used. It's a matter of chaining together sequences of Barriers, Triggers, and Futures to remove the need to keep explicit track of internal state on each Update call.

In this case, I'm using a lot of timed futures because it's a real-time card game and there are time limits.

Notes

Verbose Logging

When using Verbose() be mindful that the arguments passed into the log will be evaluated even if the verbosity is set lower than would print. Be diligent when using interpolated strings or complex functions in Verbose logging. e.g.

Verbosity = 10;
Verbose(15, $"Result of complex function: {ComplexFunction()}.");
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].