Giter Site home page Giter Site logo

omnisci3nce / riot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riot-ml/riot

0.0 0.0 0.0 1.22 MB

An actor-model multi-core scheduler for OCaml 5 ๐Ÿซ

Home Page: https://riot.ml

License: Other

Erlang 0.50% OCaml 97.62% Standard ML 0.23% Nix 1.66%

riot's Introduction

riot logo

An actor-model multi-core scheduler for OCaml 5.

Quick Start | Tutorial | Reference ย ย 

Riot is an actor-model multi-core scheduler for OCaml 5. It brings Erlang-style concurrency to the language, where lightweight processes communicate via message-passing.

open Riot

type Message.t += Hello_world

let () =
  Riot.run @@ fun () ->
  let pid =
    spawn (fun () ->
        match receive () with
        | Hello_world ->
            Logger.info (fun f -> f "hello world from %a!" Pid.pp (self ()));
            shutdown ())
  in
  send pid Hello_world

At its core Riot aims to offer:

  • Automatic multi-core scheduling โ€“ when you spawn a new Riot process, it will automatically get allocated on a random scheduler.

  • Lightweight processes โ€“ spawn 10 or 10,000 processes as you see fit.

  • Fast, type-safe message passing

  • Selective receive expressions โ€“ when receiving messages, you can skim through a process mailbox to consume them in arbitrary order.

  • Process links and monitors to keep track of the lifecycle of processes

Riot also includes:

  • Supervisors to build process hierarchies

  • Logging and Telemetry designed to be multicore friendly

  • an Application interface to orchestrate startup/shutdown of systems

  • Generic Servers for designing encapsulated services like with Elixir's GenServer

Non-goals

At the same time, there's a few things that Riot is not, and does not aim to be.

Primarily, Riot is not a full port of the Erlang VM and it won't support several of its use-cases, like:

  • supporting Erlang or Elixir bytecode
  • hot-code reloading in live applications
  • function-call level tracing in live applications
  • ad-hoc distribution

Quick Start

opam install riot

After that, you can use any of the examples as a base for your app, and run them:

dune exec ./my_app.exe

Acknowledgments

Riot is the continuation of the work I started with Caramel, an Erlang-backend for the OCaml compiler.

It was heavily inspired by eio by the OCaml Multicore team and miou by Calascibetta Romain and the Robur team, as I learned more about Algebraic Effects. In particular the Proc_state is based on the State module in Miou.

And a thousand thanks to Calascibetta Romain and Antonio Monteiro for the discussions and feedback.

riot's People

Contributors

leostera avatar omnisci3nce avatar felipecrv avatar diogomqbm avatar metame avatar leedsjohn avatar wesleimp avatar julien-leclercq avatar danielkelshaw avatar dev380 avatar emilpriver avatar wonbyte avatar pjlast avatar rbjorklin avatar smorimoto avatar amitsingh19975 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.