add std.event.RwLock and a few more std changes

* add std.event.RwLock and std.event.RwLocked
 * std.debug.warn does its printing locked
 * add std.Mutex, however it's currently implemented as a spinlock
 * rename std.event.Group.cancelAll to std.event.Group.deinit and change
   the docs and assumptions.
 * add std.HashMap.clone
This commit is contained in:
Andrew Kelley
2018-08-01 16:26:37 -04:00
parent 3c8d4e04ea
commit e3ae2cfb52
13 changed files with 422 additions and 18 deletions

View File

@@ -23,7 +23,10 @@ pub const runtime_safety = switch (builtin.mode) {
var stderr_file: os.File = undefined;
var stderr_file_out_stream: io.FileOutStream = undefined;
var stderr_stream: ?*io.OutStream(io.FileOutStream.Error) = null;
var stderr_mutex = std.Mutex.init();
pub fn warn(comptime fmt: []const u8, args: ...) void {
const held = stderr_mutex.acquire();
defer held.release();
const stderr = getStderrStream() catch return;
stderr.print(fmt, args) catch return;
}