xref: /AOO41X/main/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java (revision 2be432768a66cc90838f6a32e76ec156f587e741)
1*2be43276SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2be43276SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2be43276SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2be43276SAndrew Rist  * distributed with this work for additional information
6*2be43276SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2be43276SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2be43276SAndrew Rist  * "License"); you may not use this file except in compliance
9*2be43276SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2be43276SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2be43276SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2be43276SAndrew Rist  * software distributed under the License is distributed on an
15*2be43276SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2be43276SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2be43276SAndrew Rist  * specific language governing permissions and limitations
18*2be43276SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2be43276SAndrew Rist  *************************************************************/
21*2be43276SAndrew Rist 
22*2be43276SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package com.sun.star.lib.uno.environments.remote;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir /**
27cdf0e10cSrcweir  * This interface is an abstraction of the various
28cdf0e10cSrcweir  * threadpool implementations.
29cdf0e10cSrcweir  * <p>
30cdf0e10cSrcweir  * @version 	$Revision: 1.7 $ $ $Date: 2008-04-11 11:20:01 $
31cdf0e10cSrcweir  * @author 	    Joerg Budischewski
32cdf0e10cSrcweir  * @author 	    Kay Ramme
33cdf0e10cSrcweir  * @see         com.sun.star.lib.uno.environments.remote.ThreadPoolFactory
34cdf0e10cSrcweir  * @see         com.sun.star.lib.uno.environments.remote.IThreadPoolFactory
35cdf0e10cSrcweir  * @since       UDK1.0
36cdf0e10cSrcweir  */
37cdf0e10cSrcweir public interface IThreadPool {
38cdf0e10cSrcweir     /**
39cdf0e10cSrcweir      * Retrieves the global threadId for the current thread.
40cdf0e10cSrcweir      * <p>
41cdf0e10cSrcweir      * @return the thread id
42cdf0e10cSrcweir      */
getThreadId()43cdf0e10cSrcweir     ThreadId getThreadId();
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	/**
46cdf0e10cSrcweir 	 * Attaches this thread to the thread pool.
47cdf0e10cSrcweir 	 * <p>
48cdf0e10cSrcweir 	 * @see                 #enter
49cdf0e10cSrcweir 	 */
attach()50cdf0e10cSrcweir 	public void attach();
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     /**
53cdf0e10cSrcweir      * As above, but hands in an already existing
54cdf0e10cSrcweir      * instance of the threadid of the current thread.
55cdf0e10cSrcweir      * Returns a handle which can be used in enter and
56cdf0e10cSrcweir      * detach calls.<p>
57cdf0e10cSrcweir      * The function exists for performance
58cdf0e10cSrcweir      * optimization reasons.
59cdf0e10cSrcweir      * @see #attach
60cdf0e10cSrcweir      */
attach( ThreadId id )61cdf0e10cSrcweir     public Object attach( ThreadId id );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	/**
64cdf0e10cSrcweir 	 * Detaches this thread from the thread pool.
65cdf0e10cSrcweir 	 * @see                 #enter
66cdf0e10cSrcweir 	 */
detach()67cdf0e10cSrcweir 	public void detach();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /**
70cdf0e10cSrcweir      * As above, but hands in an already existing
71cdf0e10cSrcweir      * instance of the threadid of the current thread
72cdf0e10cSrcweir      * and a handle returned by attach.
73cdf0e10cSrcweir      * The function exists for performance
74cdf0e10cSrcweir      * optimization reasons.
75cdf0e10cSrcweir      * @see #attach,#detach
76cdf0e10cSrcweir      */
detach( Object handle, ThreadId id )77cdf0e10cSrcweir     public void detach( Object handle, ThreadId id );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	/**
80cdf0e10cSrcweir 	 * Lets this thread enter the thread pool.
81cdf0e10cSrcweir 	 * This thread then executes all jobs put via
82cdf0e10cSrcweir 	 * <code>putJob</code> until a reply job arrives.
83cdf0e10cSrcweir 	 * <p>
84cdf0e10cSrcweir 	 * @see                 #putJob
85cdf0e10cSrcweir 	 */
enter()86cdf0e10cSrcweir 	public Object enter() throws Throwable;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	/**
89cdf0e10cSrcweir      * as above but hands in an already existing
90cdf0e10cSrcweir      * instance of the threadid of the current thread
91cdf0e10cSrcweir      * and a handle returned by attach.
92cdf0e10cSrcweir 	 * This thread then executes all jobs put via
93cdf0e10cSrcweir 	 * <code>putJob</code> until a reply job arrives.
94cdf0e10cSrcweir 	 * <p>
95cdf0e10cSrcweir 	 * @see                 #putJob
96cdf0e10cSrcweir 	 */
enter( Object handle, ThreadId id )97cdf0e10cSrcweir     public Object enter( Object handle, ThreadId id ) throws Throwable;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	/**
100cdf0e10cSrcweir 	 * Queues a job into the jobQueue of the thread belonging
101cdf0e10cSrcweir 	 * to the jobs threadId.
102cdf0e10cSrcweir 	 * <p>
103cdf0e10cSrcweir 	 * @param job       the job
104cdf0e10cSrcweir 	 */
putJob(Job job)105cdf0e10cSrcweir 	public void putJob(Job job);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	/**
108cdf0e10cSrcweir 	 * Disposes this thread pool, thus releasing
109cdf0e10cSrcweir 	 * all threads by throwing a <code>DisposedException</code> with the given
110cdf0e10cSrcweir 	 * <code>Throwable</code> cause.
111cdf0e10cSrcweir 	 * <p>
112cdf0e10cSrcweir 	 * @param throwing   the cause
113cdf0e10cSrcweir 	 */
dispose(Throwable throwable)114cdf0e10cSrcweir 	public void dispose(Throwable throwable);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	/**
118cdf0e10cSrcweir 	 * Destroys the thread pool and tries
119cdf0e10cSrcweir 	 * to join all created threads immediatly.
120cdf0e10cSrcweir 	 */
destroy()121cdf0e10cSrcweir 	public void destroy();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124