Skip to content

feature: add async.channel #17

Description

@PyXiion

Parent: #13

Implement the local coroutine channel primitive described in the parent proposal.

Required API:

local ch = async.channel({ capacity = 32 })
ch:send(value)
ch:trySend(value)
ch:recv()
ch:tryRecv()
ch.handler = function(value) end
for value in ch do end
ch:close()
ch:isClosed()

Acceptance criteria:

  • Bounded FIFO queue.
  • send suspends when full.
  • trySend never suspends.
  • recv suspends when empty.
  • tryRecv never suspends.
  • Handler and iterator are alternative consumers.
  • Close drains queued values and wakes suspended operations.
  • Values are safely snapshotted.
  • Tests cover full, empty, closed, and concurrent behavior.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions