(event0: u32, event1: u32, event2: u32)
| 508 | /// This function assumes that `context_get()` returns a `FutureState`. |
| 509 | #[doc(hidden)] |
| 510 | pub unsafe fn callback(event0: u32, event1: u32, event2: u32) -> u32 { |
| 511 | // Acquire our context-local state, assert it's not-null, and then reset |
| 512 | // the state to null while we're running to help prevent any unintended |
| 513 | // usage. |
| 514 | let state = context_get().cast::<FutureState<'static>>(); |
| 515 | assert!(!state.is_null()); |
| 516 | unsafe { |
| 517 | context_set(ptr::null_mut()); |
| 518 | } |
| 519 | |
| 520 | // Use `state` to run the `callback` function in the context of our event |
| 521 | // codes we received. If the callback decides to exit then we're done with |
| 522 | // our future so deallocate it. Otherwise put our future back in |
| 523 | // context-local storage and forward the code. |
| 524 | unsafe { |
| 525 | let rc = (*state).callback(event0, event1, event2); |
| 526 | if rc == CallbackCode::Exit { |
| 527 | drop(Box::from_raw(state)); |
| 528 | } else { |
| 529 | context_set(state.cast()); |
| 530 | } |
| 531 | rtdebug!(" => (cb) {rc:?}"); |
| 532 | rc.encode() |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | /// Run the specified future to completion, returning the result. |
| 537 | /// |
no test coverage detected