riot-lib:An actor-model multi-core scheduler for OCaml 5 🐫

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

分支2Tags9
58458b64创建于 2024年10月23日356次提交
文件最后提交记录最后更新时间
feat: update Riot to work with OCaml 5.2 + 5.1 (#94) * Use nix-ocaml overlays + fmt nix flake * Include Metame's changes + update test matrix to include OCaml 5.21 年前
feat: make runtime shutdowns fast 1 年前
fix: update example 3 to use `receive_any` (#95) 1 年前
feat: add permissions to file open calls 1 年前
feat: make runtime shutdowns fast 1 年前
chore(tools): update trace processor 2 年前
chore: mark fixtures as vendored 2 年前
fix: drop tls/ssl support If you need TLS you can terminate it outside of the runtime. This will help us drop a bunch of dependencies too. Also get rid of Cstruct. 1 年前
boot 2 年前
docs: use proper dune-release changelog format 2 年前
docs: coc, license, contrib, and readme updates 2 年前
docs(nix): Add nix section to contrib guide (#77) 2 年前
feat: implement SSL Reader/Writer for stream sockets (#23) * feat: include SSL sockets * feat: expose SSL.of_socket * doc: update licenses * feat: SSL for client and socket servers2 年前
fix: expose a single public library 2 年前
feat: add SSL and update to later TLS version (#99) 1 年前
feat: update Riot to work with OCaml 5.2 + 5.1 (#94) * Use nix-ocaml overlays + fmt nix flake * Include Metame's changes + update test matrix to include OCaml 5.21 年前
feat: update Riot to work with OCaml 5.2 + 5.1 (#94) * Use nix-ocaml overlays + fmt nix flake * Include Metame's changes + update test matrix to include OCaml 5.21 年前
feat: add SSL and update to later TLS version (#99) 1 年前
fix: disable unsupported platforms 2 年前

riot logo

OCaml 5 的基于演员模型的的多核调度器。

快速入门 | 教程 | 参考手册   

Riot 是一个为 OCaml 5 设计的基于演员模型的多核调度器。它为该语言引入了类似于Erlang风格的并发编程,轻量级进程通过消息传递进行通信。

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

Riot 核心目标在于提供以下功能:

  • 自动多核调度 – 当您创建一个新的 Riot 进程时,它将自动被分配到随机的调度器上。

  • 轻量级进程 – 根据需要创建 10 个或 10,000 个进程。

  • 快速且类型安全的信息传递

  • 选择性接收表达式 – 在接收消息时,您可以浏览进程邮箱以任意顺序消费消息。

  • 进程链接与监控 以跟踪进程的生命周期

Riot 还包括以下功能:

  • 监控器 用于构建进程层次结构

  • 日志记录遥测 功能,旨在支持多核友好

  • 应用程序 接口,用于编排系统的启动/关闭

  • 通用服务器 用于设计封装服务,类似于 Elixir 的 GenServer

非目标

与此同时,Riot 有一些它不是也不打算成为的东西。

首先,Riot 不是 Erlang 虚拟机的完整移植版本,它不支持其中的许多用例,例如:

  • 支持 Erlang 或 Elixir 字节码
  • 在运行中的应用程序中进行热代码重载
  • 在运行中的应用程序中进行函数调用级别的跟踪
  • 临时分布式

快速入门

opam install riot

此后,您可以使用 示例 中的任何一个作为您应用的基础,并运行它们:

dune exec ./my_app.exe

致谢

Riot 项目是我之前工作的延续,最初始于Caramel项目,这是一个为 OCaml 编译器提供 Erlang 后端的项目。

该项目受到了OCaml Multicore团队开发的eio项目和Calascibetta Romain以及Robur团队miou项目的深刻启发,当时我正在更深入地学习代数效应。特别是Proc_state的实现,是基于Miou项目中的State模块。

非常感谢Calascibetta RomainAntonio Monteiro的讨论和反馈。

下载使用量

0

项目总下载次数(含Clone、Pull、 zip 包及 release 下载),每日凌晨更新

语言类型

OCaml97.66%
Nix1.62%
Erlang0.51%
Standard ML0.21%