how to access tcpstream in different tasks #4059
Answered
by
Darksonn
ActivePeter
asked this question in
Q&A
-
I have a loop task to receive data and I saved the tcpstream rwlock to send with it in other tasks. But in the receive loop the socket is locked when calling the read so other tasks can not write. |
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
Aug 23, 2021
Replies: 1 comment 1 reply
-
Do not put the socket behind a mutex. For simple use-cases, you can use the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Darksonn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do not put the socket behind a mutex. For simple use-cases, you can use the
split
orinto_split
methods on the socket. For more complicated sharing, a common alternative is to use the actor pattern.