Changeset 12634


Ignore:
Timestamp:
04/24/10 22:31:36 (12 years ago)
Author:
ehuelsmann
Message:

Implement THREADS:THREAD-JOIN.

Patch by: David Kirkman dkirkman _at_ ucsd dot com.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/LispThread.java

    r12587 r12634  
    4949       new ConcurrentHashMap<Thread,LispThread>();
    5050
     51    LispObject threadValue = NIL;
     52
    5153    private static ThreadLocal<LispThread> threads = new ThreadLocal<LispThread>(){
    5254        @Override
     
    8890            {
    8991                try {
    90                     funcall(wrapper,
     92                    threadValue = funcall(wrapper,
    9193                            new LispObject[] { fun },
    9294                            LispThread.this);
     
    931933    };
    932934
     935    private static final Primitive THREAD_JOIN =
     936        new Primitive("thread-join", PACKAGE_THREADS, true, "thread",
     937                      "Waits for thread to finish.")
     938    {
     939        @Override
     940        public LispObject execute(LispObject arg)
     941        {
     942            // join the thread, and returns it's value.  The second return
     943            // value is T if the thread finishes normally, NIL if its
     944            // interrupted.
     945            if (arg instanceof LispThread) {               
     946                final LispThread joinedThread = (LispThread) arg;
     947                final LispThread waitingThread = currentThread();
     948                try {
     949                    joinedThread.javaThread.join();
     950                    return
     951                        waitingThread.setValues(joinedThread.threadValue, T);
     952                } catch (InterruptedException e) {
     953                    waitingThread.processThreadInterrupts();
     954                    return
     955                        waitingThread.setValues(joinedThread.threadValue, NIL);
     956                }
     957            } else {
     958                return type_error(arg, Symbol.THREAD);
     959            }
     960        }
     961    };
     962
     963
    933964    public static final long javaSleepInterval(LispObject lispSleep)
    934965
Note: See TracChangeset for help on using the changeset viewer.