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