On Tue, Jan 26, 2021 at 1:23 PM Matthew Flatt <mfl...@cs.utah.edu> wrote:

> At Tue, 26 Jan 2021 10:25:42 +0100, Ryan Culpepper wrote:
> > This "works", but is it reliably safe to use place-channel-put from an OS
> > thread?
>
> No. It's not intended to work from an arbitrary OS thread, and because
> `place-channel-put` touches the thread scheduler to enter atomic mode,
> I can imagine that it might go wrong either now or with some small
> future change.
>
> > Or is there a better way to do this?
>
> Probably the only way currently is to use `unsafe-poller`. See
> "rktrl.rkt" in "readline" for an example. It would make sense to make
> that part of `ffi/unsafe/thread` or a new `ffi/unsafe` library. (It
> would also be good to add `unsafe-make-signal-received` to
> `ffi/unsafe/schedule`.)
>

Thanks for the pointer! Those sound useful, but in the spirit of maximum
caution, is there a guarantee that the write to the box from the new OS
thread will be visible to the original Racket OS thread when the poller
tries to read it? Is `box-cas!` or one of the memory-order operations
needed?

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33qm9Fu%3DxPWSG%2BPRoG9Pbfddo0FJQLnb_CWr8isvCmGNSfQ%40mail.gmail.com.

Reply via email to