Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTighten Send and Sync requirements #443
Conversation
cuviper
reviewed
Sep 19, 2017
| @@ -278,7 +285,7 @@ impl<'scope> Scope<'scope> { | |||
|
|
|||
| // the `Scope` is not send or sync, and we only give out | |||
| // pointers to it from within a worker thread | |||
| debug_assert!(!WorkerThread::current().is_null()); | |||
| debug_assert!(!worker_thread.is_null()); | |||
This comment has been minimized.
This comment has been minimized.
cuviper
Sep 19, 2017
Author
Member
Note, Scope now does implement Sync, so this comment isn't true anymore. We need to evaluate whether that's actually safe. I think here, this !is_null() should probably be a full assert!, and perhaps we assert that the current registry matches that saved in the Scope too.
cuviper
reviewed
Sep 19, 2017
| @@ -278,7 +285,7 @@ impl<'scope> Scope<'scope> { | |||
|
|
|||
| // the `Scope` is not send or sync, and we only give out | |||
| // pointers to it from within a worker thread | |||
| debug_assert!(!WorkerThread::current().is_null()); | |||
| debug_assert!(!worker_thread.is_null()); | |||
|
|
|||
| let worker_thread = &*worker_thread; | |||
| worker_thread.push(job_ref); | |||
This comment has been minimized.
This comment has been minimized.
cuviper
Sep 19, 2017
Author
Member
Maybe this can just switch to scope.registry.inject_or_push(job_ref), so if the scope does get carried out of the threadpool, it still spawns back to the right pool. The 'scope lifetime should still ensure the right stuff...
This comment has been minimized.
This comment has been minimized.
cuviper
requested a review
from
nikomatsakis
Sep 19, 2017
cuviper
force-pushed the
cuviper:job-sync
branch
from
f780bcd
to
dea9acf
Sep 19, 2017
nikomatsakis
reviewed
Sep 22, 2017
|
|
||
| let worker_thread = &*worker_thread; | ||
| worker_thread.push(job_ref); | ||
| self.registry.inject_or_push(job_ref); |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Sep 22, 2017
Member
Let's add a comment here saying that it would be unsafe to just invoke push before we don't know that the scope was not somehow sent to another thread.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
requested changes
Sep 22, 2017
|
Left a nit with a minor documentation change, but otherwise looks good. |
cuviper
added some commits
Sep 19, 2017
cuviper
force-pushed the
cuviper:job-sync
branch
from
dea9acf
to
829c1ea
Sep 23, 2017
cuviper
referenced this pull request
Sep 23, 2017
Closed
Nesting `.install` calls causes deadlock #446
cuviper
added some commits
Sep 23, 2017
This comment has been minimized.
This comment has been minimized.
|
Added a fix for #446, since that also needed the change to |
cuviper commentedSep 19, 2017
This is a breaking change to
rayon-core, necessary for soundness.Scope::spawnnow requiresSendfor the closure. Fixes #430.ThreadPool::installnow requiresSendfor the return value.(unstable)
internal::Tasknow requiresSend + Syncinstead of justSend, so its use ofArcproperly implementsSendandSynctoo.