client pool app #1966
-
What's a recommended pattern for using a pool of clients to feed back results to a common thread? I'm thinking an event loop, and a client thread for each CPU messaging back to primary thread. No need for a server, just client-side. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't think you can gain anything from a stand alone client pool for awc. When using a pool for client you mostly aiming to reuse TcpStream for specific domain/socket address and in awc this happens only on single thread. Which means you can not really share one TcpStream across threads and it stays on the thread you establish that stream. (There is no public API to move a stream between threads in awc and even if you can the underlying event is still polled by the runtime it's registered). I would suggest you use reqwest for a thread safe approach where you share a unified stream pool. |
Beta Was this translation helpful? Give feedback.
I don't think you can gain anything from a stand alone client pool for awc.
When using a pool for client you mostly aiming to reuse TcpStream for specific domain/socket address and in awc this happens only on single thread. Which means you can not really share one TcpStream across threads and it stays on the thread you establish that stream. (There is no public API to move a stream between threads in awc and even if you can the underlying event is still polled by the runtime it's registered).
I would suggest you use reqwest for a thread safe approach where you share a unified stream pool.