At Thu, 5 Dec 2019 14:26:17 -0500, David Storrs wrote:
> My understanding is that parameters are copied between threads, but I'm not
> sure how this interacts with things like file ports, network connections,
> etc.  Would the following code be problematic?
> 
> 
> (define conn (make-parameter))
> (define s (udp-open-socket))
> (udp-bind! s #f  12345)
> (conn s)
> 
> (thread (thunk (udp-send-to (conn) "8.8.8.8" 55555 #"hi from bob")))
> (thread (thunk (udp-send-to (conn) "8.8.8.8" 55555 #"hi from fred")))

Yes, this works.

As you say, a thread inherits parameter values (at the time that the
thread is created) from its creating thread, and a UDP socket can be
used from multiple threads at once and isn't tied to any particular
thread, so using `(conn)` in different threads is fine.

-- 
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/20191205211101.41EDF650182%40mail-svr1.cs.utah.edu.

Reply via email to