-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure ShardSenders are dropped before ShardWriter #13
base: master
Are you sure you want to change the base?
Conversation
calling finish on ShardWriter or dropping ShardWriter
Pull Request Test Coverage Report for Build 59
💛 - Coveralls |
Interesting! I think this means we can't send the ShardSender to a new thread, because there's no way to ensure that a thread finishes with a static lifetime. scoped threads are an option: https://docs.rs/crossbeam/0.6.0/crossbeam/thread/index.html |
We could just mediate that with an Arc instead of a bare reference. The get_sender convenience API may need to go away though.. |
Actually, we could implement a trait to carry get_sender and implement it for Arc. |
I think Sreenath's idea is to force the lifetime of the sender to be less than the lifetime of the writer, so that when you drop / call finish() on the writer, you're guaranteed to be done sending. If we put the writer in Arc<> then I think we have the same problem as now: you can close the writer before the senders. (As an aside, we should see if we can do |
@nlhepler - sorry - if the sender is inside Arc<>, then you can't call finish() on it. You'd need something like 'join' that could wait until all the other handles are gone, then gives you back exclusive ownership. That could deadlock on a single thread if you don't drop the senders before you 'join'. |
Yeah, I don't see a way to work around both lifetime order and
Is this reasonable? |
@@ -1,2 +1,3 @@ | |||
target | |||
Cargo.lock | |||
test.shardio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an end-of-line character to this file. Best to configure your text editor to ensure that text files end with an end-of-line character.
Changes
ShardWriter
insideShardSender
ShardSender<T>
is nowShardSender<'a, T, S>
S: Send
, but that should not be restrictive at allIllegal code
API usage of the form:
will not compile with a clear message
Legal code
You can either not call
finish()
:or explicitly scope the
sender
and call finish