Skip to content

Implement more communication primitives #1255

Closed
@boggle

Description

@boggle

We are lacking at least one critical primitive:

  • recv on port<T> with timeout that returns an option<T>

It may be desirable to recv from multiple ports at once, which may need

  • recv on [port<T>] that returns (uint, T)
  • recv on [port<T>] with timeout that returns option<(uint, T)>
  • recv_some on [port<T>] with timeout that returns [T] or [(int, T)]
  • These calls assume a fixed message type, it would be nice if it was possible to
    recv from a set of differently typed ports at once and match on the result somehow

These calls perhaps would be useful for sending to many channels:

  • send_any(value: T, channels: [chan<T>]) that returns the uint vec index of the channel actually used
    • with the channel selected fairly from channels
  • send_ready(value: T, channels: [chan<T>]) that returns the uint vec index of the channel actually used
    • with the channel selected fairly among ready channels from channels
  • send_all(value: T, channels: [chan<T>])
    • for convenience

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions