Implementing Concurrency
- What is a subprocess?
A subprocess is a child process started by a parent process. The child process must remain under the parent process to continue to be called a subprocess.
- Why is fork called fork?
fork means a split (process), like a fork in the road, or a forked tongue.
- Is fork still useful?
Yes! If you have access to it on your system. For example, the heartbeat pattern is much more elegant with fork.
- When were threads standardized?
Threads have never been universally standardized. The Posix standard introduced threads in 1995. Notably, Windows provides no standard or guarantees regarding thread behavior. There are similarities, but no standard.
- Why is move sometimes needed for thread closures?
Move tells the compiler that it is OK to transfer ownership of captured variables to the closure.
- What is the difference between
Send
andSync
traits?
Sync
is a stronger assertion of thread-safety—a type is Send
if it is safe to send it to another thread. A type is Sync
if it is safe to share between threads.
- What are we allowed to lock, then mutate Mutex without an unsafe block?
The compiler has determined that Mutex is already safe to use and meets certain requirements for safety. That is not to say that bad things can't happen—a Mutex will poison itself if one of its MutexGuards
(the thing it returns when a lock is obtained) is dropped during a panic. Any future attempts to lock the Mutex will return an Err
or panic!
.