37 if (_interrupt_event != NULL) { |
37 if (_interrupt_event != NULL) { |
38 CloseHandle(_interrupt_event); |
38 CloseHandle(_interrupt_event); |
39 } |
39 } |
40 } |
40 } |
41 |
41 |
42 // We need to specialize these to interact with the _interrupt_event. |
42 // We need to specialize this to interact with the _interrupt_event. |
43 |
|
44 volatile bool OSThread::interrupted() { |
|
45 return _interrupted != 0 && |
|
46 (WaitForSingleObject(_interrupt_event, 0) == WAIT_OBJECT_0); |
|
47 } |
|
48 |
43 |
49 void OSThread::set_interrupted(bool z) { |
44 void OSThread::set_interrupted(bool z) { |
50 if (z) { |
45 if (z) { |
51 _interrupted = 1; |
|
52 // More than one thread can get here with the same value of osthread, |
|
53 // resulting in multiple notifications. We do, however, want the store |
|
54 // to interrupted() to be visible to other threads before we post |
|
55 // the interrupt event. |
|
56 OrderAccess::release(); |
|
57 SetEvent(_interrupt_event); |
46 SetEvent(_interrupt_event); |
58 } |
47 } |
59 else { |
48 else { |
60 // We should only ever clear the interrupt if we are in fact interrupted, |
49 // We should only ever clear the interrupt if we are in fact interrupted, |
61 // and this can only be done by the current thread on itself. |
50 // and this can only be done by the current thread on itself. |
62 assert(_interrupted == 1, "invariant for clearing interrupt state"); |
|
63 _interrupted = 0; |
|
64 ResetEvent(_interrupt_event); |
51 ResetEvent(_interrupt_event); |
65 } |
52 } |
66 } |
53 } |