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

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

Example Problem

  • printing at the REPL looks through a deref (e.g. on a promise)
    • this can block (possibly forever) if a data structure contains e.g. a promise
  • if a deref is potentially blocking, then I don't think the REPL should perform the deref
    • option 1: never deref possible blockers
    • option 2: have a bindable val that controls how REPL prints blocking derefs, analogous to the controls for lazy data structures
  • in any case, there needs to be a way to discover which derefs might block

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
Labels: