The Thread module provides threads, timers, synchronization primitives and task execution:
- PIThread — run a loop or one-off work in a separate thread. Override run() or use the default loop; start/stop with start() and stop(). Can act as the event performer for PIObject (see Threading and events).
- PITimer — periodic callbacks at a given frequency (e.g. Hz). Connect to a handler; start/stop the timer. Used in Getting started and in state machine examples.
- Synchronization — PIMutex, PISpinlock, PIConditionVariable, PISemaphore, PIReadWriteLock for protecting shared data and coordinating threads.
- PIThreadPoolExecutor — submit tasks to a fixed pool of worker threads; wait for completion or shutdown.
- PIThreadPoolLoop — run a function over a range in parallel (parallel-for style).
- PIBlockingDequeue — blocking producer-consumer queue for passing work between threads.
Use PIMutexLocker (and similar guards) for exception-safe locking. Events from other threads can be queued and processed in the object's thread via callQueuedEvents() (see Events and Event handlers). Full API: pithread.h, pitimer.h, pimutex.h, pithreadpoolexecutor.h, piblockingqueue.h, pithreadmodule.h.