2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.lib
.uno
.environments
.remote
;
22 * This interface is an abstraction of the various threadpool implementations.
24 * @see com.sun.star.lib.uno.environments.remote.ThreadPoolFactory
25 * @see com.sun.star.lib.uno.environments.remote.IThreadPoolFactory
28 public interface IThreadPool
{
30 * Retrieves the global threadId for the current thread.
32 * @return the thread id.
34 ThreadId
getThreadId();
37 * Attaches this thread to the thread pool.
44 * As above, but hands in an already existing instance of the threadid of
47 * <p>The function exists for performance.</p>
49 * @return Returns a handle which can be used in enter and detach calls.
52 Object
attach( ThreadId id
);
55 * Detaches this thread from the thread pool.
61 * As above, but hands in an already existing instance of the threadid of
62 * the current thread and a handle returned by attach.
64 * <p>The function exists for performance.</p>
69 void detach( Object handle
, ThreadId id
);
72 * Lets this thread enter the thread pool.
74 * <p>This thread then executes all jobs put via <code>putJob</code> until
75 * a reply job arrives.</p>
79 Object
enter() throws Throwable
;
82 * As above but hands in an already existing instance of the threadid of
83 * the current thread and a handle returned by attach.
85 * <p>This thread then executes all jobs put via <code>putJob</code> until
86 * a reply job arrives.</p>
90 Object
enter( Object handle
, ThreadId id
) throws Throwable
;
93 * Queues a job into the jobQueue of the thread belonging to the jobs
101 * Disposes this thread pool, thus releasing all threads by throwing a
102 * <code>DisposedException</code> with the given <code>Throwable</code> cause.
104 * @param throwable the cause
106 void dispose(Throwable throwable
);
110 * Destroys the thread pool and tries to join all created threads immediately.