← board

Native Pascal TThread class (M3)

Invariant

Threading is opt-in, off by default; the single-threaded self-build stays byte-identical. No libc — built on [[feature-pal-thread-primitives]] (syscalls only). Milestones land in any order under [[meta-multithreading]].

Scope

The FPC-compatible TThread surface so Pascal threads "just work", on the PAL (no libc):

Acceptance

Status — M3 first slice LANDED (2026-06-30)

DONE (x86-64, pure RTL — no compiler change):

REMAINING in M3 (FPC-compat surface):

Update — Terminate/Terminated + ReturnValue (2026-06-30)

TThread now has FPC cooperative cancellation: Terminate sets a Terminated flag the Execute body polls (while not Self.Terminated do ...); plus ReturnValue (Integer, Execute sets, joiner reads after WaitFor). test_tthread_terminate in make test-threads. NOTE: unqualified property access in a method is a pxx gap ([[bug-unqualified-property-in-method]]) so Execute must write Self.Terminated / Self.ReturnValue for now — filed Track A. Still remaining: Synchronize/Queue, virtual destructor/auto-join (needs virtual TObject.Destroy), OnTerminate, CurrentThread, classes re-export.

Update — Synchronize/Queue + auto-join destructor (2026-07-02, v152)

Pure-RTL slice in palthreadobj (compiler binary unchanged, hash identical):

Still remaining: FreeOnTerminate (self-free needs join-self guard), OnTerminate, CurrentThread, Suspend/Resume, classes re-export.

Update — M3 COMPLETE: FreeOnTerminate, OnTerminate, CurrentThread, Suspend/Resume (2026-07-03)

Pure-RTL slice in palthreadobj (no compiler change):

Deliberately NOT done: classes re-export (kept isolated in palthreadobj to not destabilise the shared unit — unchanged from the prior decision); priority (no PAL surface for it).