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
-
Replying to @yoshuawuyts
This almost seems like having a database (standalone or in-mem one) with thread local caching? Do you have an example of what kind of code would use that pattern?
1 reply 0 retweets 0 likes -
Replying to @bitshiftmask
haha, so this is for a logger. Actually believe
@sheevink suggested this. But the idea is to capture log messages into a thread-local bump allocator, and then every ~250ms we wake a driver thread that swaps the bump allocators and then logs the messages.2 replies 0 retweets 2 likes -
Replying to @yoshuawuyts @sheevink
Would it make sense to just have a thread local owned, heap allocated, vec, and when you're done filling it (size or time limited), then push the vec into a channel? Drain the channel from the log emitting thread?
2 replies 0 retweets 1 like
yosh Retweeted Jakub Valtar
Yeah perhaps! -- This sounds similar to what Jakub was suggesting; might give this a shot!https://twitter.com/jakubvaltar/status/1264326532216115203 …
yosh added,
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.