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

Strategy for getting threadLocal pointer in each thread #45

Open
peheje opened this issue Oct 28, 2017 · 1 comment
Open

Strategy for getting threadLocal pointer in each thread #45

peheje opened this issue Oct 28, 2017 · 1 comment

Comments

@peheje
Copy link

peheje commented Oct 28, 2017

From the docs:
"It's recommended to not call withThreadLocal(_:) or get the threadLocal pointer each individual time it's needed. Retrieving the thread-local instance incurs avoidable overhead."

That means right now I'm passing the:
let threadLocal = Xoroshiro.threadLocal

From the thread into my functions e.g.:
init(_ theadLocalRandom: UnsafeMutablePointer<Xoroshiro>) { ..

Is there a better way? Could RandomKit cache the UnsafeMutablePointer for each thread so that the application programmer didn't have to think about passing the thread owned pointer to each function called by the thread?

Thanks for the awesome repository and software 👍

@peheje
Copy link
Author

peheje commented Oct 28, 2017

I tried to use your ThreadLocal library. But I get worse performance than passing the UnsafeMutablePointer. https://www.dropbox.com/s/sc7v7afdlv9kt91/threadLocal.mov?dl=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant