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

Facts

  • deref can 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

Wants

  • I want to know if reading a value will block
    • future-done? for Future
  • I want to know if something has finished
    • await for Agent
    • future-done? for Future
    • Thread.isAlive (rare)
  • I want to wait for something to finish
    • await for Agent
    • deref for Future, Delay, and Promise
  • I want to wait a specific amount of time for something to finish
    • await-for for Agent
  • I want to prevent something from happening
    • future-cancel for Future
    • ThreadPoolExecutor.remove for a custom thread pool
    • Avoid deref on a Delay
Labels: