pub struct Answer<T> { /* private fields */ }
Expand description
An answer to a completed Future.
The are two times we need to wait on a future running to completion: the outer initial executor invocation from the main thread, and running an async thread which will have a join method.
For both cases, we will use a Semaphore to indicate when the data is available.
The main issue is that this type is intended to be one shot. Trying to load a second value will invalidate the data structure (the item will be replaced, but there is a race with the semaphore).
TODO: Currently, the data is stored inside of a Mutex. This isn’t actually necessary (the semaphore already manages the coordination), and only a memory barrier would be needed, which would be provided by the semaphore. So, this should be changed to just unsafely share the data, similar to how a mutex is implemented.