We prefer to encourage the use of event loops (see unix::poll or hare-ev) for multiplexing I/O operations, or multiprocessing with shared memory if you need to use CPU resources in parallel.
It is, strictly speaking, possible to create threads in a Hare program. You can link to libc and use pthreads, or you can use the clone(2) syscall directly. Operating systems implemented in Hare, such as Helios, often implement multi-threading.
However, the upstream standard library does not make reentrancy guarantees, so you are solely responsible for not shooting your foot off.
> multiprocessing with shared memory if you need to use CPU resources in parallel
This is actually pretty powerful. I personally prefer it for most purposes, because it restricts the possibility of data races to only the shared memory regions. It's a little like an "unsafe block" of memory with respect to data races.
Though this limitation will limit its adoption in this multicore age I think:
From the FAQ https://harelang.org/documentation/faq.html
....
Can I use multithreading in Hare?
Probably not.
We prefer to encourage the use of event loops (see unix::poll or hare-ev) for multiplexing I/O operations, or multiprocessing with shared memory if you need to use CPU resources in parallel.
It is, strictly speaking, possible to create threads in a Hare program. You can link to libc and use pthreads, or you can use the clone(2) syscall directly. Operating systems implemented in Hare, such as Helios, often implement multi-threading.
However, the upstream standard library does not make reentrancy guarantees, so you are solely responsible for not shooting your foot off.