xref: /AOO41X/main/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package com.sun.star.lib.uno.environments.remote;
29 
30 /**
31  * This interface is an abstraction of the various
32  * threadpool implementations.
33  * <p>
34  * @version     $Revision: 1.7 $ $ $Date: 2008-04-11 11:20:01 $
35  * @author      Joerg Budischewski
36  * @author      Kay Ramme
37  * @see         com.sun.star.lib.uno.environments.remote.ThreadPoolFactory
38  * @see         com.sun.star.lib.uno.environments.remote.IThreadPoolFactory
39  * @since       UDK1.0
40  */
41 public interface IThreadPool {
42     /**
43      * Retrieves the global threadId for the current thread.
44      * <p>
45      * @return the thread id
46      */
47     ThreadId getThreadId();
48 
49     /**
50      * Attaches this thread to the thread pool.
51      * <p>
52      * @see                 #enter
53      */
54     public void attach();
55 
56     /**
57      * As above, but hands in an already existing
58      * instance of the threadid of the current thread.
59      * Returns a handle which can be used in enter and
60      * detach calls.<p>
61      * The function exists for performance
62      * optimization reasons.
63      * @see #attach
64      */
65     public Object attach( ThreadId id );
66 
67     /**
68      * Detaches this thread from the thread pool.
69      * @see                 #enter
70      */
71     public void detach();
72 
73     /**
74      * As above, but hands in an already existing
75      * instance of the threadid of the current thread
76      * and a handle returned by attach.
77      * The function exists for performance
78      * optimization reasons.
79      * @see #attach,#detach
80      */
81     public void detach( Object handle, ThreadId id );
82 
83     /**
84      * Lets this thread enter the thread pool.
85      * This thread then executes all jobs put via
86      * <code>putJob</code> until a reply job arrives.
87      * <p>
88      * @see                 #putJob
89      */
90     public Object enter() throws Throwable;
91 
92     /**
93      * as above but hands in an already existing
94      * instance of the threadid of the current thread
95      * and a handle returned by attach.
96      * This thread then executes all jobs put via
97      * <code>putJob</code> until a reply job arrives.
98      * <p>
99      * @see                 #putJob
100      */
101     public Object enter( Object handle, ThreadId id ) throws Throwable;
102 
103     /**
104      * Queues a job into the jobQueue of the thread belonging
105      * to the jobs threadId.
106      * <p>
107      * @param job       the job
108      */
109     public void putJob(Job job);
110 
111     /**
112      * Disposes this thread pool, thus releasing
113      * all threads by throwing a <code>DisposedException</code> with the given
114      * <code>Throwable</code> cause.
115      * <p>
116      * @param throwing   the cause
117      */
118     public void dispose(Throwable throwable);
119 
120 
121     /**
122      * Destroys the thread pool and tries
123      * to join all created threads immediatly.
124      */
125     public void destroy();
126 }
127 
128