Skip to content

Instantly share code, notes, and snippets.

@nickfargo
Created August 13, 2015 22:20
Show Gist options
  • Save nickfargo/ac3bc8e981dc13d495ed to your computer and use it in GitHub Desktop.
Save nickfargo/ac3bc8e981dc13d495ed to your computer and use it in GitHub Desktop.

Both core.async and js-csp reverted their “promise channel” implementation. Reasoning given appears to reference this issue.

However, the described anomalous behavior does not appear to be present in prochan, as demonstrated by this case added to test suite:

  it "keeps its promises", async ->
    ch = chan.promise()

    p1 = proc ->
      value = yield receive ch
      assert.equal value, 42
      yield send waiter, 'p1'
    p2 = proc ->
      value = yield receive ch
      assert.equal value, 42
      yield send waiter, 'p2'

    waiter = proc ->
      n = 2
      yield receive() while n--

    sleeper = proc ->
      yield sleep 1
      yield send ch, 42

    assert.deepEqual (yield receive waiter), ['p1', 'p2']

Ad-hoc testing of equivalent in js-csp also did not appear to present failure case, either. Yet js-csp chose to revert also, perhaps in deference to cljs(?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment