Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A trivial future / lightweight thread library built on cl-cont delimited continuations.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.markdown
Octocat-spinner-32 cl-future-test.asd
Octocat-spinner-32 cl-future.asd
README.markdown

CL-FUTURE

DEPRECATED in favor of GREEN-THREADS. You might also be looking for a different library named CL-FUTURE.

A trivial future / lightweight thread library built on cl-cont delimited continuations.

Usage

;; example 1: futures

(defparameter *f1* (make-future))
(defparameter *f2* nil)

(register-action
  (lambda ()
    (with-call/cc
      (let ((f2 (make-future)))
        (princ "Hello, ")
        (setf *f2* f2)
        (wait-for *f1*)
        (wait-for f2)
        (princ "World.")
        nil))))

(register-action
  (lambda ()
    (with-call/cc
      (wait-for *f1*)
      (princ "... "))))

(register-action (lambda () (complete-future *f2* 'someval)))
(register-action (lambda () (complete-future *f1* 'someval)))

(run-actions)
;; output: Hello, ... World.

;; example 2: cooperative multitasking

(register-action
  (lambda ()
    (with-call/cc
      (dolist (letter (list "a" "b" "c" "d"))
        (princ letter)
        (yield)))))

(register-action
  (lambda ()
    (with-call/cc
      (dolist (number (list "1" "2" "3" "4"))
        (princ number)
        (yield)))))

(run-actions)
;; output: a1b2c3d4

Installation

Stick this repo in ~/quicklisp/local-projects and load with (ql:quickload :cl-future).

Author

Copyright

Copyright (c) 2012 Stephen A. Goss (steveth45@gmail.com)

License

Licensed under the Modified BSD License.

Something went wrong with that request. Please try again.