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

Function context_and_sync_function

src/lib.rs:104–118  ·  view source on GitHub ↗
(closure: &mut Option<F>)

Source from the content-addressed store, hash-verified

102}
103
104fn context_and_sync_function<F>(closure: &mut Option<F>) ->
105 (*mut c_void, dispatch_function_t)
106 where F: FnOnce() {
107 extern fn work_read_closure<F>(context: &mut Option<F>) where F: FnOnce() {
108 // This is always passed Some, so it's safe to unwrap
109 let closure = context.take().unwrap();
110 closure();
111 }
112
113 let context: *mut Option<F> = closure;
114 let func: extern fn(&mut Option<F>) = work_read_closure::<F>;
115 unsafe {
116 (context as *mut c_void, mem::transmute(func))
117 }
118}
119
120fn context_and_apply_function<F>(closure: &F) ->
121 (*mut c_void, extern fn(*mut c_void, usize))

Callers 3

onceMethod · 0.85
exec_syncMethod · 0.85
barrier_syncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected