[armedbear-cvs] r12634 - trunk/abcl/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Sat Apr 24 22:31:39 UTC 2010
Author: ehuelsmann
Date: Sat Apr 24 18:31:36 2010
New Revision: 12634
Log:
Implement THREADS:THREAD-JOIN.
Patch by: David Kirkman dkirkman _at_ ucsd dot com.
Modified:
trunk/abcl/src/org/armedbear/lisp/LispThread.java
Modified: trunk/abcl/src/org/armedbear/lisp/LispThread.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispThread.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/LispThread.java Sat Apr 24 18:31:36 2010
@@ -48,6 +48,8 @@
final static ConcurrentHashMap<Thread,LispThread> map =
new ConcurrentHashMap<Thread,LispThread>();
+ LispObject threadValue = NIL;
+
private static ThreadLocal<LispThread> threads = new ThreadLocal<LispThread>(){
@Override
public LispThread initialValue() {
@@ -87,7 +89,7 @@
public void run()
{
try {
- funcall(wrapper,
+ threadValue = funcall(wrapper,
new LispObject[] { fun },
LispThread.this);
}
@@ -930,6 +932,35 @@
}
};
+ private static final Primitive THREAD_JOIN =
+ new Primitive("thread-join", PACKAGE_THREADS, true, "thread",
+ "Waits for thread to finish.")
+ {
+ @Override
+ public LispObject execute(LispObject arg)
+ {
+ // join the thread, and returns it's value. The second return
+ // value is T if the thread finishes normally, NIL if its
+ // interrupted.
+ if (arg instanceof LispThread) {
+ final LispThread joinedThread = (LispThread) arg;
+ final LispThread waitingThread = currentThread();
+ try {
+ joinedThread.javaThread.join();
+ return
+ waitingThread.setValues(joinedThread.threadValue, T);
+ } catch (InterruptedException e) {
+ waitingThread.processThreadInterrupts();
+ return
+ waitingThread.setValues(joinedThread.threadValue, NIL);
+ }
+ } else {
+ return type_error(arg, Symbol.THREAD);
+ }
+ }
+ };
+
+
public static final long javaSleepInterval(LispObject lispSleep)
{
More information about the armedbear-cvs
mailing list