[m-rev.] for review: Add interface for joinable threads.
Julien Fischer
jfischer at opturion.com
Fri Feb 23 11:20:44 AEDT 2024
Hi Peter,
On Thu, 22 Feb 2024, Peter Wang wrote:
> It is often necessary to be certain that a thread has terminated before
> the rest of the program can continue. In some cases, signalling that a
> thread is ABOUT to terminate (using any synchronisation device)
> is insufficient: even after the last piece of Mercury code has run,
> the thread still has additional cleanup code to run, which might include
> arbitrary code in thread-specific data destructors, etc.
>
> Introduce a predicate to create a joinable native thread,
> and a predicate to wait for that thread to terminate (joining).
>
> Joinable threads are only implemented for C backends for now.
I assume you have at given some consideration that the API proposed for
joinable threads is implementable for Java and C#?
> library/thread.m:
> Add new predicates spawn_native_joinable and join_thread.
>
> Add a internal type thread_handle.
>
> Rename the internal type thread_id type to thread_desc,
> as thread_id is too similar to thread_handle.
>
> tests/hard_coded/Mmakefile:
> tests/hard_coded/spawn_native_joinable.exp:
> tests/hard_coded/spawn_native_joinable.exp2:
> tests/hard_coded/spawn_native_joinable.m:
> Add test case.
>
> NEWS.md:
> Announce changes.
The diff looks fine.
Julien.
More information about the reviews
mailing list