Skip to content

Getting started

Install

# flake.nix
inputs.cl-concurrent-kit = {
  url = "github:nerima-lisp/cl-concurrent-kit/v0.4.2";
  inputs.nixpkgs.follows = "nixpkgs";
};

Or, from a plain ASDF setup, clone the repository somewhere on your CL_SOURCE_REGISTRY and:

(asdf:load-system "cl-concurrent-kit")

A future

(cl-concurrent-kit:await (cl-concurrent-kit:future (+ 1 2 3)))
;; => 6

A channel

(let ((channel (cl-concurrent-kit:make-channel)))
  (cl-concurrent-kit:future (cl-concurrent-kit:send channel :hello))
  (cl-concurrent-kit:recv channel))
;; => :HELLO, T

A structured-concurrency scope

(cl-concurrent-kit:with-task-scope (scope)
  (let ((a (cl-concurrent-kit:spawn scope (lambda () (+ 1 2))))
        (b (cl-concurrent-kit:spawn scope (lambda () (* 3 4)))))
    (+ (cl-concurrent-kit:await a) (cl-concurrent-kit:await b))))
;; => 15, and both tasks are guaranteed to have finished before this returns.

Next: Core concepts for the ideas behind each layer, or Recipes for more worked examples.