Skip to content
/ vows Public

A synchronization scheme for Common Lisp based on promise keeping, in the tradition of E.

Notifications You must be signed in to change notification settings

bhyde/vows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vows

Vows is a common lisp package which layers on top of bordeaux-threads. Currently very rough.

Playing with the ideas mentioned here http://en.wikipedia.org/wiki/Futures_and_promises. But only enough to get a tool needed for some simple parallelism in yet another experiment.

Dictionary

vow:vow is a class which represents a promise to perform some work. Access to this class should be done while holding the bt:lock found in it's vow::lock slot. It's vow::run-state slot maybe queried to get a sense of it's status; see the code.

vow::promise-keeper is a class consisting of a list of promises to keep and a pool of threads which labor to fulfil those promises.

vow:promise-keeper is the current promise keeper, and instance of vow::promise-keeper.

vow:vow lambda returns a vow:vow representing the promise to do the work of the lambda after adding it to the todo list of the current promise keeper.

vow:fulfiled? vow nil or the vow if it has been fufilled.

vow:fulfil vow blocks until the given vow has been fufilled and then returns it's result, which may have multiple values or be an error.

vow:find-fulfilled vows returns a vow from the list vows that has been fufilled, blocking if necessary.

vow:broken-vow the subclass of simple-error used to denote the condition of created with by vow:break-vow.

vow:break-vow vow Fulfils the vow as if it had suffered the simple error vow:broken-vow. Blocks until it can gain a lock on the promise keeper. It then either removes the vow from his to do list, or if one of his minions is currently working on keeping this promise it forces that attempt to unwind. It marks the vow as having been fufill by the error vow:broken-vow, even if the vow is already fufilled.

Missing stuff and notes

Missing: Triggers

Because the above design encourages blocking it is bogus.

Instead, as in E, fulfillment should just trigger the running of continuation code. Possibly this is something like:

trigger a datum representing some work to enqueue once some promise has been fulfilled. The trigger may run immediately, later when the promise is fulfilled. Note the trigger can run when the promise is broken.

vow:add-trigger vow lambda a method on a vow that creates and returns an additional trigger on that vow.

vow:remove-trigger vow trigger a method on a vow. returns nil. after calling this the trigger will no longer be pending for that vow.

Missing abstractions on sets of vows.

There are some patterns vow/tigger/continuations that should be given first class status. In particular various triggering patterns on the fulfillment of sets of vows.

  • N triggers
    • for each vow fulfilled trigger
  • 1 trigger
    • when all vows fulfilled trigger
    • when any one fulfilled trigger, and then break the other vows.

Promise keeper

I doubt I've got the right design for the promise keeper. He's entirely naive, as written, about what order to work on his todo list and that seems extremely unlikely to be the right approach.

In fact I'm confident that it would be possible to have all threads in the pool blocked on I/O while there are other items in the

Affordances

In theory it should be possible to implement subclasses of promise-keeper and promise.

About

A synchronization scheme for Common Lisp based on promise keeping, in the tradition of E.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages