diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-28 19:32:16 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-12-28 19:44:02 -0800 |
| commit | f3370295b738c8b4c80fa8fc8449c0c3545b1b35 (patch) | |
| tree | af7e479999400cf75e414583e9b5edd4fa553f34 /src/rustllvm/RustWrapper.cpp | |
| parent | c0d4abf8c5d368fb6861fb015c82811e94b7566b (diff) | |
| download | rust-f3370295b738c8b4c80fa8fc8449c0c3545b1b35.tar.gz rust-f3370295b738c8b4c80fa8fc8449c0c3545b1b35.zip | |
Implement a Once primitive for initialization
Of the 8 static mutexes that are currently in-use by the compiler and its libraries, 4 of them are currently used for one-time initialization. The unforunate side effect of using a static mutex is that the mutex is leaked. This primitive should provide the basis for efficiently keeping track of one-time initialization as well as ensuring that it does not leak the internal mutex that is used. I have chosen to put this in libstd because libstd is currently making use of a static initialization mutex (rt::local_ptr), but I can also see a more refined version of this type being suitable to initialize FFI bindings (such as initializing LLVM and initializing winsock networking on windows). I also intend on adding "helper threads" to libnative, and those will greatly benefit from a simple "once" primitive rather than always reinventing the wheel by using mutexes and bools. I would much rather see this primitive built on a mutex that blocks green threads appropriately, but that does not exist at this time, so it does not belong outside of `std::unstable`.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
