Support joinable threads in C# and Java backends.

library/thread.m:
    Implement spawn_native_joinable and join_thread for C# and Java.

    Rename the existing Java helper class RunGoal to RunGoalDetached.
    Add RunGoalJoinable.

    Rename the C# helper MercuryThread to RunGoalDetached, to match the
    Java backend. Add RunGoalJoinable.

java/runtime/MercuryThreadPool.java:
    Replace submitExclusiveThread() method with createExclusiveThread(),
    which returns the newly created thread, without starting it.
This commit is contained in:
Peter Wang
2024-02-26 12:42:14 +11:00
parent 4ea65113d8
commit 4dd926b54d
2 changed files with 181 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
// vim: ts=4 sw=4 expandtab ft=java
//
// Copyright (C) 2014, 2016, 2018 The Mercury Team
// Copyright (C) 2014, 2016, 2018, 2024 The Mercury team.
// This file is distributed under the terms specified in COPYING.LIB.
//
@@ -134,12 +134,11 @@ public class MercuryThreadPool
/**
* Create a new thread to execute the given task.
* @param task The task the new thread should execute.
* @return The task.
* @return The new thread.
*/
public void submitExclusiveThread(Task task)
public MercuryThread createExclusiveThread(Task task)
{
Thread t = thread_factory.newThread(task);
t.start();
return thread_factory.newThread(task);
}
/**