fubark / cyber

Fast and concurrent scripting.
https://cyberscript.dev
MIT License
1.18k stars 40 forks source link

Make static variables thread-local #36

Open dumblob opened 1 year ago

dumblob commented 1 year ago

In response to https://github.com/fubark/cyber/issues/11#issuecomment-1408977386 I wonder if making static variables thread-local would serve the purpose they do now with the great benefit of being safe and fast for multithreading?

Related: https://github.com/fubark/cyber/commit/0d800438baf11e074540be5c1429060d0667420a

fubark commented 1 year ago

Does this add overhead for single threaded use case? I'm also not clear about how Cyber will do threading at both the script level and embedded level, so this is not urgent.

dumblob commented 1 year ago

It should not add basically any overhead. Nim uses only thread-local variables everywhere and Nim's peformance is equal to C in single-threaded.