Error formatting macro: pagetree: java.lang.NullPointerException
Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

Current Non-Blocking Behavior

  • Promise
  • Delay
    • Blocks on read if value is not cached
    • Read with force or deref
  • Future
    • Blocks on read if computation not finished
    • future-done?
    • deref calls .get
    • Implements java.util.concurrent.Future
      • .get
      • .get with timeout
      • .isCancelled
      • .isDone
      • .cancel
  • Agents
    • Reads never block
    • await (no timeout) and await-for (timeout)
      • Uses CountDownLatch
  • Vars, Atoms, and Refs
    • Reads never block

Summary of Current Behavior

Which types have blocking reads?

DEREF CAN BLOCK

DEREF NEVER BLOCKS

Promise

Agent

Future

Atom

Delay

Var

 

Ref

What are the APIs?

TYPE

"DO BLOCKING ACTION"

"WILL I BLOCK?"

INTERRUPT

KIND OF BLOCK

Promise

deref

 

 

CountDownLatch

Delay

deref / force

 

 

custom

Future

deref

future-done?

future-cancel

j.u.c.Future

Agent

await / await-for

 

 

CountDownLatch

Proposed New API

These functions will be valid on all reference types – Promise, Future, Delay, Agent, Atom, Ref, and Var – although they may be no-ops on some types.

  • await
    • block until all args are done, don't care about return value
  • await-for
    • same with timeout
  • deref
    • generic read, may block depending on type
  • deref-for
    • same with timeout
  • done?
    • true if deref/await on this object will NOT block
  • cancel
    • on a Future
      • calls cancel
    • on an Agent
      • abort current action
      • clear action queue
      • further action sends throw an Exception
    • on a Promise
      • causes deliver to throw an Exception
    • on a Delay
      • clears cached value, future reads will throw an Exception
  • cancelled?
    • true if this object has been cancelled

Deprecated Type-Specific Functions

  • force
  • future-done?
  • future-cancel
Labels: