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