# M:N threading · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/eb326e15530dd6dca4ccbe7dbfde7bf048de813e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: eb326e15530dd6dca4ccbe7dbfde7bf048de813e

Requested commit: eb326e15530dd6dca4ccbe7dbfde7bf048de813e

Commit: eb326e15530dd6dca4ccbe7dbfde7bf048de813e

Tree: a20438803ab35a874750906281dc19a463be0acc

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
M:N threading

 * add std.atomic.QueueMpsc.isEmpty
 * make std.debug.global_allocator thread-safe
 * std.event.Loop: now you have to choose between
   - initSingleThreaded
   - initMultiThreaded
 * std.event.Loop multiplexes coroutines onto kernel threads
 * Remove std.event.Loop.stop. Instead the event loop run() function
   returns once there are no pending coroutines.
 * fix crash in ir.cpp for calling methods under some conditions
 * small progress self-hosted compiler, analyzing top level declarations
 * Introduce std.event.Lock for synchronizing coroutines
 * introduce std.event.Locked(T) for data that only 1 coroutine should
   modify at once.
 * make the self hosted compiler use multi threaded event loop
 * make std.heap.DirectAllocator thread-safe

See #174

TODO:
 * call sched_getaffinity instead of hard coding thread pool size 4
 * support for Windows and MacOS
 * #1194
 * #1197

```

## Parents

- [d8295c188946b0f07d62420c2f08c940f70b03ac](https://git.cafe/gitcafe/zig/commit/d8295c188946b0f07d62420c2f08c940f70b03ac?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/eb326e15530dd6dca4ccbe7dbfde7bf048de813e?format=markdown)
