MCPcopy Index your code
hub / github.com/SSheldon/rust-dispatch / barrier_sync

Method barrier_sync

src/queue.rs:236–253  ·  view source on GitHub ↗

Submits a closure to be executed on self as a barrier and waits until it completes. Barriers create synchronization points within a concurrent queue. If self is concurrent, when it encounters a barrier it delays execution of the closure (and any further ones) until all closures submitted before the barrier finish executing. At that point, the barrier closure executes by itself. Upon completion, s

(&self, work: F)

Source from the content-addressed store, hash-verified

234 /// If self is a serial queue or one of the global concurrent queues,
235 /// this method behaves like the normal `sync` method.
236 pub fn barrier_sync<T, F>(&self, work: F) -> T
237 where F: Send + FnOnce() -> T, T: Send {
238 let mut result = None;
239 {
240 let result_ref = &mut result;
241 let work = move || {
242 *result_ref = Some(work());
243 };
244
245 let mut work = Some(work);
246 let (context, work) = context_and_sync_function(&mut work);
247 unsafe {
248 dispatch_barrier_sync_f(self.ptr, context, work);
249 }
250 }
251 // This was set so it's safe to unwrap
252 result.unwrap()
253 }
254
255 /// Submits a closure to be executed on self as a barrier and returns
256 /// immediately.

Callers 2

test_barrier_syncFunction · 0.80
test_barrier_asyncFunction · 0.80

Calls 1

Tested by 2

test_barrier_syncFunction · 0.64
test_barrier_asyncFunction · 0.64