@@ -10,14 +10,24 @@ object LazyVals {
10
10
11
11
final val BITS_PER_LAZY_VAL = 2L
12
12
final val LAZY_VAL_MASK = 3L
13
+ final val debug = false
13
14
14
- @ inline def STATE (cur : Long , ord : Int ) = (cur >> (ord * BITS_PER_LAZY_VAL )) & LAZY_VAL_MASK
15
+ @ inline def STATE (cur : Long , ord : Int ) = {
16
+ val r = (cur >> (ord * BITS_PER_LAZY_VAL )) & LAZY_VAL_MASK
17
+ if (debug)
18
+ println(s " STATE( $cur, $ord) = $r" )
19
+ r
20
+ }
15
21
@ inline def CAS (t : Object , offset : Long , e : Long , v : Int , ord : Int ) = {
22
+ if (debug)
23
+ println(s " CAS( $t, $offset, $e, $v, $ord) " )
16
24
val mask = ~ (LAZY_VAL_MASK << ord * BITS_PER_LAZY_VAL )
17
25
val n = (e & mask) | (v << (ord * BITS_PER_LAZY_VAL ))
18
26
compareAndSet(t, offset, e, n)
19
27
}
20
28
@ inline def setFlag (t : Object , offset : Long , v : Int , ord : Int ) = {
29
+ if (debug)
30
+ println(s " setFlag( $t, $offset, $v, $ord) " )
21
31
var retry = true
22
32
while (retry) {
23
33
val cur = get(t, offset)
@@ -35,6 +45,8 @@ object LazyVals {
35
45
}
36
46
}
37
47
@ inline def wait4Notification (t : Object , offset : Long , cur : Long , ord : Int ) = {
48
+ if (debug)
49
+ println(s " wait4Notification( $t, $offset, $cur, $ord) " )
38
50
var retry = true
39
51
while (retry) {
40
52
val cur = get(t, offset)
@@ -68,7 +80,12 @@ object LazyVals {
68
80
monitors(id)
69
81
}
70
82
71
- @ inline def getOffset (clz : Class [_], name : String ) = unsafe.objectFieldOffset(clz.getDeclaredField(name))
83
+ @ inline def getOffset (clz : Class [_], name : String ) = {
84
+ val r = unsafe.objectFieldOffset(clz.getDeclaredField(name))
85
+ if (debug)
86
+ println(s " getOffset( $clz, $name) = $r" )
87
+ r
88
+ }
72
89
73
90
object Names {
74
91
final val state = " STATE"
0 commit comments