ladybird/Userland/Libraries/LibThreading
kleines Filmröllchen 2fcb713037 LibThreading: Overhaul thread behavior with ThreadState
This replaces all state-related variables with a single ThreadState.
These are simplified over what the Kernel has, but capture all
userspace-available thread state.

Locking the state behind an atomic and using proper atomic operations
also gets rid of quite some deadlocks and race conditions that have
existed around m_tid and others beforehand.

In terms of behavior, this introduces the following changes:
- All thread state mishandling (e.g. joining a detached thread) crashes
  the program. Mishandling thread state is a severe kind of concurrency
  bug that might also be indeterministic, so letting it silently
  disappear with the return value of pthread_ APIs is a bad idea. The
  thread state can always be checked beforehand to ensure that no crash
  happens.
- Destructing a still-running thread will crash in AK/Function, so the
  Thread destructor issues its own warning for debugging purposes.
- Thread issues warnings before crashes in many places to aid
  concurrency debugging (the most difficult kind of debugging).
- Joining dead but not detached threads is legal, as per POSIX APIs.
- The thread ID is never reset to 0 after the thread has been started
  and subsequently been assigned a valid thread ID. The thread's exit
  state is still obtainable.
- Detaching threads that are about to exit is considered a programming
  bug and will often (not always, as we can't catch all execution
  sequences involved in such a situation) crash the program on purpose.
  If you want to detach a thread that will definitely exit on its own,
  you have to prevent it from exiting before detach() was called (e.g.
  with an "exit requested" flag).
2022-12-11 19:07:20 -07:00
..
BackgroundAction.cpp LibThreading: Set BackgroundAction's thread name correctly 2022-10-31 00:02:13 +01:00
BackgroundAction.h Libraries: Use default constructors/destructors in LibThreading 2022-03-13 22:34:38 +01:00
CMakeLists.txt Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
ConditionVariable.h Everywhere: Use my new serenityos.org e-mail :^) 2022-01-14 11:54:09 +01:00
Mutex.h Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
MutexProtected.h LibThreading: Introduce MutexProtected generic synchronization primitive 2022-01-23 15:21:10 +01:00
Thread.cpp LibThreading: Overhaul thread behavior with ThreadState 2022-12-11 19:07:20 -07:00
Thread.h LibThreading: Overhaul thread behavior with ThreadState 2022-12-11 19:07:20 -07:00