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
;
21 final class NativeThreadPool
implements IThreadPool
{
22 public NativeThreadPool() {
26 public ThreadId
getThreadId() {
27 return new ThreadId(threadId());
30 public void attach() {
34 public Object
attach(ThreadId id
) {
39 public void detach() {
43 public void detach(Object handle
, ThreadId id
) {
47 public Object
enter() throws Throwable
{
48 Job job
= enter(pool
);
55 public Object
enter(Object handle
, ThreadId id
) throws Throwable
{
59 public void putJob(Job job
) {
61 pool
, job
.getThreadId().getBytes(), job
, job
.isRequest(),
62 job
.isRequest() && !job
.isSynchronous());
65 public void dispose(Throwable throwable
) {
70 public void destroy() {
74 // The native implementation is in
75 // bridges/source/jni_uno/nativethreadpool.cxx:
77 System
.loadLibrary("java_uno");
79 private static native byte[] threadId();
80 private static native long create();
81 private static native void attach(long pool
);
82 private static native Job
enter(long pool
);
83 private static native void detach(long pool
);
84 private static native void putJob(
85 long pool
, byte[] threadId
, Job job
, boolean request
, boolean oneWay
);
86 private static native void dispose(long pool
);
87 private static native void destroy(long pool
);
89 private final long pool
;
90 private volatile Throwable dispose
;