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: NativeThreadPool.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
;
33 final class NativeThreadPool
implements IThreadPool
{
34 public NativeThreadPool() {
38 public ThreadId
getThreadId() {
39 return new ThreadId(threadId());
42 public void attach() {
46 public Object
attach(ThreadId id
) {
51 public void detach() {
55 public void detach(Object handle
, ThreadId id
) {
59 public Object
enter() throws Throwable
{
60 Job job
= enter(pool
);
67 public Object
enter(Object handle
, ThreadId id
) throws Throwable
{
71 public void putJob(Job job
) {
73 pool
, job
.getThreadId().getBytes(), job
, job
.isRequest(),
74 job
.isRequest() && !job
.isSynchronous());
77 public void dispose(Throwable throwable
) {
82 public void destroy() {
86 // The native implementation is in
87 // bridges/source/jni_uno/nativethreadpool.cxx:
89 System
.loadLibrary("java_uno");
91 private static native byte[] threadId();
92 private static native long create();
93 private static native void attach(long pool
);
94 private static native Job
enter(long pool
);
95 private static native void detach(long pool
);
96 private static native void putJob(
97 long pool
, byte[] threadId
, Job job
, boolean request
, boolean oneWay
);
98 private static native void dispose(long pool
);
99 private static native void destroy(long pool
);
101 private final long pool
;
102 private volatile Throwable dispose
;