Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc channels #657

Open
timotheecour opened this issue Mar 17, 2021 · 4 comments
Open

misc channels #657

timotheecour opened this issue Mar 17, 2021 · 4 comments

Comments

@timotheecour
Copy link
Owner

timotheecour commented Mar 17, 2021

/cc @xflywind

links

@timotheecour
Copy link
Owner Author

  • add func recv*[T](c: Channel[T]): T {.inline.} = overload to system/channels_builtin

so that it's easy to migrate back and forth bw std/channels and system/channels_builtin

let dest = chan.recv()

@timotheecour
Copy link
Owner Author

  • add channels.clear (or channels.flush) to flush (and destroy) all messages in flight not yet received

functionally equivalent to:

block:
  var dst: T
  while true:
    if not tryRecv(chan, dst): break

or (maybe less efficient?)

while true:
  var dst: T
  if not tryRecv(chan, dst): break

(need to ensure it's as efficient as possible and doesn't leak, ie destructors for isolate data should be called on each received item)

@timotheecour
Copy link
Owner Author

timotheecour commented Mar 17, 2021

  • we need an overload for recv with a timeout (tryRecv is not a substitute for that)

@timotheecour
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant