Current Non-Blocking Behavior
- Promise
- Blocks on read
- Uses CountDownLatch
- Calls .await on deref, no timeout
- 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
- 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
- on a Future
- cancelled?
- true if this object has been cancelled
Deprecated Type-Specific Functions
- force
- future-done?
- future-cancel
Labels: