jonhoo / left-right

A lock-free, read-optimized, concurrency primitive.
Apache License 2.0
1.95k stars 94 forks source link

Is there a way to get the backing data structure out? #93

Closed pYtoner closed 3 years ago

pYtoner commented 3 years ago

Once we create a writer and reader is there a way to get the underlying data out?

It would be the opposite of left_right::new_from_empty<T, _>

Something like left_right::consume_writer<O>(writer: WriteHandle<T, O>) -> T

It would be only safe to do this once all the readers moved on from the current write side. And the readers could still read the read side so we don't need to consume them.

Would something like this be possible?

jonhoo commented 3 years ago

At the moment, no, there isn't, but yes, I think this should be possible basically by doing what we currently do in Drop just in a separate method called something like take. I'd be happy to review a PR!

pYtoner commented 3 years ago

I'll start working on it..

pYtoner commented 3 years ago

Added a new PR for it.

pYtoner commented 3 years ago

Since 0.11.3 the way to do this is with WriteHandle::take