Facts
derefcan block- Never for Var, Ref, Agent, and Atom
- Sometimes for Future, Delay, and Promise
- Java APIs
- Future
.get()blocks until complete- interruptible, throws InterruptedException
.get(long, TimeUnit)blocks for specified duration- throws TimeouotException if it times out
- interruptible, throws InterruptedException
.isDone()asks if finished.cancel(bool mayInterrupt)attempts to cancel- if already finished or cancelled, returns false
- if already running, tries to interrupt if argument is true
.isCancellled()asks if cancelled
- CountDownLatch
.await()blocks until latch reaches zero- interruptible, throws InterruptedException
.await(long, TimeUnit)blocks until latch reaches zero- returns false if it times out
- interruptible, throws InterruptedException
.getCount()returns current count
- Semaphore
- CyclicBarrier
- Future
Wants
- I want to know if reading a value will block
future-done?for Future
- I want to know if something has finished
awaitfor Agentfuture-done?for FutureThread.isAlive(rare)
- I want to wait for something to finish
awaitfor Agentdereffor Future, Delay, and Promise
- I want to wait a specific amount of time for something to finish
await-forfor Agent
- I want to prevent something from happening
future-cancelfor FutureThreadPoolExecutor.removefor a custom thread pool- Avoid
derefon a Delay
Labels: