Replies: 1 comment 1 reply
-
In a multi-thread runtime, you can use On a current-thread runtime, the possibilities are much more limited. If option 3 works, then you could do that, but if your initialization requires any runtime resources (e.g. if it needs to do any async IO), then it is simply impossible. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a simplification, but
one_time_initialize
must complete beforemain_task
starts.one_time_initialize
has to be sync for compatibility with other parts of the system (a refactor is possible, but it's kind of a last resort).I have considered or tried the following:
Handle::current().block_on(|| ...)
within the sync functions: this panics because of using runtimes within runtimestask::spawn_blocking
: This works without conflict, but it doesn't stop the current thread's executionmpsc
channel that blocks untilone_time_initialize
sends completion status (orthread::park
)Option 3 seems like the best but none of these options seem all that great, so I'm simply wondering if there is a better solution. Completely stopping the main runtime until
one_time_initialize
is acceptable and probably necessary, but I'm not sure how to do that.Beta Was this translation helpful? Give feedback.
All reactions