Could use some help from Rust Twitter on this one: I want to provide each thread with a Vec in a thread-local. Then from another thread I want to periodically take ownership of the thread-local vecs and swap them with empty ones. Is there a good pattern/lib for this?
-
Show this thread
-
I'm thinking I could make this work with an Arc<Mutex<Vec>> stored in the thread-local, and sending a clone over the the driver thread. But it feels like this should be doable using a compare-and-swap of sorts, but unsure how to make this work correctly. This should be common?
6 replies 0 retweets 0 likesShow this thread -
Replying to @yoshuawuyts
threads are producers, and you want a kind of asynchronous / batching / chunking collector, to avoid locking on every item? something like bbqueue? swapping leases on the two regions between the threads?
1 reply 0 retweets 1 like
Replying to @redtwitdown
"swapping leases" -- that sounds about what I want to be doing. Hmm, yeah perhaps?
3:58 PM - 23 May 2020
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.