Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parameter pack for Env threads #8285

Closed
pdillinger opened this issue May 11, 2021 · 0 comments
Closed

Support parameter pack for Env threads #8285

pdillinger opened this issue May 11, 2021 · 0 comments

Comments

@pdillinger
Copy link
Contributor

I tend to use std::thread because it supports functional static polymorphism with parameter packs. In other words, I can create a thread from an arbitrary function by providing arguments to the function, with full type checking, rather than casting through a single void *.

Filed at request of @mrambacher in #8225

This support could probably be generically bolted on in Env by wrapping a target with parameters in a heap-allocated std::function<void()>*, cast to void *, and in an unwrapper, cast back, executed, and deleted.

facebook-github-bot pushed a commit that referenced this issue May 19, 2021
Summary:
- Add class `FunctorWrapper` to invoke the function with given parameters
- Implement `StartThreadTyped` which wraps `StartThread` with type checking cover
- Demonstrate `StartThreadTyped` in test `util/thread_local_test.cc`

#8285

Pull Request resolved: #8303

Reviewed By: ajkr

Differential Revision: D28539318

Pulled By: pdillinger

fbshipit-source-id: 624789c236bde31163deda95c1e1471aee68933e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant