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

Method exec_sync

src/queue.rs:136–153  ·  view source on GitHub ↗

Submits a closure for execution on self and waits until it completes.

(&self, work: F)

Source from the content-addressed store, hash-verified

134
135 /// Submits a closure for execution on self and waits until it completes.
136 pub fn exec_sync<T, F>(&self, work: F) -> T
137 where F: Send + FnOnce() -> T, T: Send {
138 let mut result = None;
139 {
140 let result_ref = &mut result;
141 let work = move || {
142 *result_ref = Some(work());
143 };
144
145 let mut work = Some(work);
146 let (context, work) = context_and_sync_function(&mut work);
147 unsafe {
148 dispatch_sync_f(self.ptr, context, work);
149 }
150 }
151 // This was set so it's safe to unwrap
152 result.unwrap()
153 }
154
155 /// Submits a closure for asynchronous execution on self and returns
156 /// immediately.

Callers 5

test_serial_queueFunction · 0.80
test_sync_ownedFunction · 0.80
test_serial_queue_asyncFunction · 0.80
test_suspendFunction · 0.80
promptFunction · 0.80

Calls 1

Tested by 4

test_serial_queueFunction · 0.64
test_sync_ownedFunction · 0.64
test_serial_queue_asyncFunction · 0.64
test_suspendFunction · 0.64