1 |
/* |
2 |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
* Expert Group and released to the public domain. Use, modify, and |
4 |
* redistribute this code in any way without acknowledgement. |
5 |
*/ |
6 |
|
7 |
package java.util.concurrent; |
8 |
import java.util.concurrent.locks.*; |
9 |
import sun.misc.Unsafe; |
10 |
import java.lang.reflect.*; |
11 |
|
12 |
/** |
13 |
* Tempoarary class for preliminary release only; not part of JSR-166. |
14 |
* Contains native methods for some classes introduced in JSR166 |
15 |
* @since 1.5 |
16 |
* @author Doug Lea |
17 |
*/ |
18 |
public final class JSR166Support { |
19 |
private static native void registerNatives(); |
20 |
static { |
21 |
registerNatives(); |
22 |
} |
23 |
|
24 |
/** |
25 |
* Native implementation of trylock entry in Locks.attempt. |
26 |
*/ |
27 |
public static native boolean tryLockEnter(Object o); |
28 |
|
29 |
/** |
30 |
* Native implementation of trylock exit in Locks.attempt. |
31 |
*/ |
32 |
public static native void tryLockExit(Object o); |
33 |
|
34 |
/** |
35 |
* Native implementation of Locks.newConditionFor(obj).wait() |
36 |
*/ |
37 |
public static native void conditionWait(Object obj, |
38 |
Object cond |
39 |
) throws InterruptedException; |
40 |
|
41 |
|
42 |
/** |
43 |
* Native implementation of Locks.newConditionFor(obj).waitNanos() |
44 |
*/ |
45 |
public static native long conditionRelWait(Object obj, |
46 |
Object cond, |
47 |
long nanos) throws InterruptedException; |
48 |
|
49 |
/** |
50 |
* Native implementation of Locks.newConditionFor(obj).waitUntil() |
51 |
*/ |
52 |
public static native boolean conditionAbsWait(Object obj, |
53 |
Object cond, |
54 |
long deadline) throws InterruptedException; |
55 |
|
56 |
/** |
57 |
* Native implementation of Locks.newConditionFor(obj).signal() |
58 |
*/ |
59 |
public static native void conditionNotify(Object base, Object cond); |
60 |
|
61 |
/** |
62 |
* Native implementation of Locks.newConditionFor(obj).signalAll() |
63 |
*/ |
64 |
public static native void conditionNotifyAll(Object base, Object cond); |
65 |
|
66 |
/** |
67 |
* Native implementation of TimeUnit.nanoTime |
68 |
*/ |
69 |
public static native long currentTimeNanos(); |
70 |
|
71 |
/** |
72 |
* Native implementation of LockSupport.park |
73 |
*/ |
74 |
public static native void park(boolean isAbsolute, long time); |
75 |
|
76 |
/** |
77 |
* Native implementation of LockSupport.unpark |
78 |
*/ |
79 |
public static native void unpark(Object thread); |
80 |
|
81 |
} |