90 class HandshakeState {
91 friend ThreadSelfSuspensionHandshake;
92 friend SuspendThreadHandshake;
93 friend UnsafeAccessErrorHandshake;
94 friend JavaThread;
95 // This a back reference to the JavaThread,
96 // the target for all operation in the queue.
97 JavaThread* _handshakee;
98 // The queue containing handshake operations to be performed on _handshakee.
99 FilterQueue<HandshakeOperation*> _queue;
100 // Provides mutual exclusion to this state and queue. Also used for
101 // JavaThread suspend/resume operations.
102 Monitor _lock;
103 // Set to the thread executing the handshake operation.
104 Thread* volatile _active_handshaker;
105
106 bool claim_handshake();
107 bool possibly_can_process_handshake();
108 bool can_process_handshake();
109
110 bool have_non_self_executable_operation();
111 HandshakeOperation* get_op_for_self(bool allow_suspend, bool check_async_exception);
112 HandshakeOperation* get_op();
113 void remove_op(HandshakeOperation* op);
114
115 void set_active_handshaker(Thread* thread) { Atomic::store(&_active_handshaker, thread); }
116
117 class MatchOp {
118 HandshakeOperation* _op;
119 public:
120 MatchOp(HandshakeOperation* op) : _op(op) {}
121 bool operator()(HandshakeOperation* op) {
122 return op == _op;
123 }
124 };
125
126 public:
127 HandshakeState(JavaThread* thread);
128 ~HandshakeState();
129
130 void add_operation(HandshakeOperation* op);
131
132 bool has_operation() { return !_queue.is_empty(); }
|
90 class HandshakeState {
91 friend ThreadSelfSuspensionHandshake;
92 friend SuspendThreadHandshake;
93 friend UnsafeAccessErrorHandshake;
94 friend JavaThread;
95 // This a back reference to the JavaThread,
96 // the target for all operation in the queue.
97 JavaThread* _handshakee;
98 // The queue containing handshake operations to be performed on _handshakee.
99 FilterQueue<HandshakeOperation*> _queue;
100 // Provides mutual exclusion to this state and queue. Also used for
101 // JavaThread suspend/resume operations.
102 Monitor _lock;
103 // Set to the thread executing the handshake operation.
104 Thread* volatile _active_handshaker;
105
106 bool claim_handshake();
107 bool possibly_can_process_handshake();
108 bool can_process_handshake();
109
110 bool has_handshaker_operation();
111 HandshakeOperation* get_op_for_self(bool allow_suspend, bool check_async_exception);
112 HandshakeOperation* get_op_for_handshaker();
113 void remove_op(HandshakeOperation* op);
114
115 void set_active_handshaker(Thread* thread) { Atomic::store(&_active_handshaker, thread); }
116
117 class MatchOp {
118 HandshakeOperation* _op;
119 public:
120 MatchOp(HandshakeOperation* op) : _op(op) {}
121 bool operator()(HandshakeOperation* op) {
122 return op == _op;
123 }
124 };
125
126 public:
127 HandshakeState(JavaThread* thread);
128 ~HandshakeState();
129
130 void add_operation(HandshakeOperation* op);
131
132 bool has_operation() { return !_queue.is_empty(); }
|