Re: [racket-users] synchronization with ffi/unsafe/os-thread

2021-01-26 Thread Ryan Culpepper
On Tue, Jan 26, 2021 at 3:06 PM Matthew Flatt wrote: > At Tue, 26 Jan 2021 14:49:22 +0100, Ryan Culpepper wrote: > > 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

Re: [racket-users] synchronization with ffi/unsafe/os-thread

2021-01-26 Thread Matthew Flatt
At Tue, 26 Jan 2021 14:49:22 +0100, Ryan Culpepper wrote: > 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

Re: [racket-users] synchronization with ffi/unsafe/os-thread

2021-01-26 Thread Ryan Culpepper
On Tue, Jan 26, 2021 at 1:23 PM Matthew Flatt 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 >

Re: [racket-users] synchronization with ffi/unsafe/os-thread

2021-01-26 Thread Matthew Flatt
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

[racket-users] synchronization with ffi/unsafe/os-thread

2021-01-26 Thread Ryan Culpepper
I'm trying to figure out how to use ffi/unsafe/os-thread to call a long-running foreign function in an OS thread to avoid blocking other Racket threads. I want to communicate the result of the foreign call to the original Racket thread and have it wake up when the call completes. Normally I could