async-executor icon indicating copy to clipboard operation
async-executor copied to clipboard

StaticLocalExecutor usage example?

Open jbr opened this issue 1 year ago • 0 comments

I was excited to see the addition of StaticExecutor and StaticLocalExecutor optimizations, and started async-global-executor#17 with the intent to adopt both of them. However, it is unclear from the examples how exactly to use StaticLocalExecutor.

The documentation suggests using it with thread_local!, but LocalKey intentionally only offers scoped lifetime access in with in order to prevent usage from other threads. StaticLocalExecutor::spawn requires &'static self, which cannot be directly obtained from tls. Does that lifetime have to be 'static? If so, how is this intended to be used?

Thanks!

jbr avatar May 28 '24 19:05 jbr