Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


田中秀宗です。

Java側のコードを見つけました。
jurt.jar のソースコードを以下に貼ります。

どうも、タイムアウトして例外を発生させ、Nullが返っているようです。


https://svn.apache.org/repos/asf/openoffice/trunk/main/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java


(No.1)Line 80
        public Object enter( ) throws Throwable {
        ThreadId threadId = getThreadId();
return enter( _javaThreadPoolFactory.getJobQueue( threadId ), threadId );
        }

https://svn.apache.org/repos/asf/openoffice/trunk/main/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java

(No.3)Line 295
        /**
         * Enters the job queue.
         * <p>
         * @return the result of the final job (reply)
         * @param  disposeId  a dispose id
         */
        Object enter(Object disposeId) throws Throwable {
                return enter(0, disposeId); // wait infinitly
        }

(No.2)Line 322
        /**
         * Enters the job queue.
         * <p>
         * @return the result of the final job (reply)
* @param waitTime the maximum amount of time to wait for a job (0 means wait infinitly)
         * @param  disposeId  a dispose id
         */
        Object enter(int waitTime, Object disposeId) throws Throwable {
if(DEBUG) System.err.println("#####" + getClass().getName() + ".enter: " + _threadId);

                boolean quit = false;

                Object hold_disposeId = _disposeId;
                _disposeId = disposeId;

                Object result = null;

                Thread hold_worker_thread = _worker_thread;
                _worker_thread = Thread.currentThread();

                while(!quit) {
                        Job job = null;
                        
                        try {
                                job = removeJob(waitTime);
                                
                                if(job != null) {
                                        try {
                                                result = job.execute();
                                        }
                                        finally {
                                                _active = false;
                                        }

                                        if (!job.isRequest()) {
                                                job.dispose();

                                                quit = true;
                                        }

                                        job = null;
                                }
                                else
                                        quit = true;

                                
                        }
                        finally { // ensure that this queue becomes disposed, if necessary
if(DEBUG) System.err.println("##### " + getClass().getName() + ".enter leaving: " + _threadId + " " + _worker_thread + " " + hold_worker_thread + " " + result);

                                synchronized(this) {
                                        if(job != null || (quit && _head == null)) {
                                                _worker_thread = hold_worker_thread;

                                                _createThread_now = true;
                                        
                                                _disposeId = hold_disposeId;

                                                if(_sync_jobQueue != null)
notifyAll(); // notify waiters (e.g. this is an asyncQueue and there is a sync waiting)
                                        }
                                        else
                                                quit = false;

                                }
                        }
                }

                return result;
        }


(No.4)Line 202
        /**
         * Removes a job from the queue.
         * <p>
         * @return a job or null if timed out ■■■■ここも注目!
         * @param  waitTime        the maximum amount of time to wait for a job
         */
        private Job removeJob(int waitTime) {
if(DEBUG) System.err.println("##### " + getClass().getName() + ".removeJob:" + _head + " " + _threadId);

                Job job = null;
                synchronized (this) {
                        // wait max. waitTime time for a job to enter the queue
                        boolean waited = false;
                        while(_head == null && (waitTime == 0 || !waited)) {
                                if(_doDispose == _disposeId) {
                                        _doDispose = null;
                                        throw (DisposedException) ■■■■■■■■■■■■■■■■■■■■ここ!
                        new DisposedException().initCause(_throwable);
                                }

                                // notify sync queues
                                notifyAll();

                                try {
                                        // wait for new job
                                        wait(waitTime);
                                }
                                catch(InterruptedException interruptedException) {
throw new com.sun.star.uno.RuntimeException(getClass().getName() + ".removeJob - unexpected:" + interruptedException);
                                }
                                
                                // signal that we have already waited once
                                waited = true;
                        }


                        if(_head != null) {
                                Job current = _head;
                                _head    = _head._next;
                                
                                if(_head == null)
                                        _tail = null;
                                
                                job = current;
                                _active = true;
                        }
                }

                // always wait for asynchron jobqueue to be finished !
                if(job != null && _async_jobQueue != null) {
                        synchronized(_async_jobQueue) {
                                // wait for async queue to be empty and last job to be done
                                while(_async_jobQueue._active || _async_jobQueue._head != null) {
if(DEBUG) System.err.println("waiting for async:" + _async_jobQueue._head + " " + _async_jobQueue._worker_thread);

                                        if(_doDispose == _disposeId) {
                                                _doDispose = null;
                                                throw (DisposedException)
                            new DisposedException().initCause(_throwable);
                                        }

                                        try {
                                                _async_jobQueue.wait();
                                        }
                                        catch(InterruptedException interruptedException) {
throw new com.sun.star.uno.RuntimeException(getClass().getName() + ".removeJob - unexpected:" + interruptedException);
                                        }
                                }
                        }
                }

                return job;
        }


--
Unsubscribe instructions: E-mail to discuss+unsubscribe@ja.libreoffice.org
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/ja/discuss/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.