1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: IThreadPool.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com
.sun
.star
.lib
.uno
.environments
.remote
;
34 * This interface is an abstraction of the various
35 * threadpool implementations.
37 * @version $Revision: 1.7 $ $ $Date: 2008-04-11 11:20:01 $
38 * @author Joerg Budischewski
40 * @see com.sun.star.lib.uno.environments.remote.ThreadPoolFactory
41 * @see com.sun.star.lib.uno.environments.remote.IThreadPoolFactory
44 public interface IThreadPool
{
46 * Retrieves the global threadId for the current thread.
48 * @return the thread id
50 ThreadId
getThreadId();
53 * Attaches this thread to the thread pool.
60 * As above, but hands in an already existing
61 * instance of the threadid of the current thread.
62 * Returns a handle which can be used in enter and
64 * The function exists for performance
65 * optimization reasons.
68 public Object
attach( ThreadId id
);
71 * Detaches this thread from the thread pool.
77 * As above, but hands in an already existing
78 * instance of the threadid of the current thread
79 * and a handle returned by attach.
80 * The function exists for performance
81 * optimization reasons.
82 * @see #attach,#detach
84 public void detach( Object handle
, ThreadId id
);
87 * Lets this thread enter the thread pool.
88 * This thread then executes all jobs put via
89 * <code>putJob</code> until a reply job arrives.
93 public Object
enter() throws Throwable
;
96 * as above but hands in an already existing
97 * instance of the threadid of the current thread
98 * and a handle returned by attach.
99 * This thread then executes all jobs put via
100 * <code>putJob</code> until a reply job arrives.
104 public Object
enter( Object handle
, ThreadId id
) throws Throwable
;
107 * Queues a job into the jobQueue of the thread belonging
108 * to the jobs threadId.
112 public void putJob(Job job
);
115 * Disposes this thread pool, thus releasing
116 * all threads by throwing the given
117 * <code>Throwable</code>.
119 * @param throwing the Throwable
121 public void dispose(Throwable throwable
);
125 * Destroys the thread pool and tries
126 * to join all created threads immediatly.
128 public void destroy();