folly icon indicating copy to clipboard operation
folly copied to clipboard

how to tell whether the current thread is an folly::executor thread or not?

Open shiyu-bytedance opened this issue 1 year ago • 1 comments

a general folly::executor question, is there a way to tell whether the current thread is an folly::executor thread or not? For example, something like an API static folly::Executor* folly::executor::getExecutor(), which returns a nullptr if current thread is not an executor thread.

shiyu-bytedance avatar Apr 12 '23 09:04 shiyu-bytedance

You may want to use thread_local variables to tell if we are in some special executor's thread.

https://github.com/facebook/folly/blob/main/folly/executors/IOThreadPoolExecutor.h#L136

Weaverzhu avatar Apr 19 '23 14:04 Weaverzhu

This is not currently a facility supported by folly executors. In particular, in any given thread, there may be multiple executors at once.

yfeldblum avatar Jun 21 '24 04:06 yfeldblum