core.async

Add drain! to consume and discard a channel

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Approval:
    Vetted

Description

Do we want this for consumer walkaway scenarios or something baked into the channel impl?

(defn drain!
 "Fully consumes and discards a channel. Returns a channel that
  closes when ch is fully drained"
 [ch]
 (go-loop []
   (if (some? (<! ch))
     (recur))))

Activity

Hide
Sam Umbach added a comment -

When a channel's buffer is full, close! and/or untap on that channel is not sufficient to unblock other taps on the same mult channel. This is a specific case when drain! is necessary; be sure to drain after untap/close to avoid a race condition.

Show
Sam Umbach added a comment - When a channel's buffer is full, close! and/or untap on that channel is not sufficient to unblock other taps on the same mult channel. This is a specific case when drain! is necessary; be sure to drain after untap/close to avoid a race condition.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated: