58 };
59
60 class VM_Handshake: public VM_Operation {
61 HandshakeThreadsOperation* const _op;
62 const jlong _handshake_timeout;
63 public:
64 bool evaluate_at_safepoint() const { return false; }
65
66 bool evaluate_concurrently() const { return false; }
67
68 protected:
69
70 VM_Handshake(HandshakeThreadsOperation* op) :
71 _op(op),
72 _handshake_timeout(TimeHelper::millis_to_counter(HandshakeTimeout)) {}
73
74 void set_handshake(JavaThread* target) {
75 target->set_handshake_operation(_op);
76 }
77
78 bool poll_for_completed_thread() { return _op->thread_has_completed(); }
79
80 bool handshake_has_timed_out(jlong start_time);
81 static void handle_timeout();
82 };
83
84 bool VM_Handshake::handshake_has_timed_out(jlong start_time) {
85 // Check if handshake operation has timed out
86 if (_handshake_timeout > 0) {
87 return os::elapsed_counter() >= (start_time + _handshake_timeout);
88 }
89 return false;
90 }
91
92 void VM_Handshake::handle_timeout() {
93 LogStreamHandle(Warning, handshake) log_stream;
94 MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
95 ALL_JAVA_THREADS(thr) {
96 if (thr->has_handshake()) {
97 log_stream.print("Thread " PTR_FORMAT " has not cleared its handshake op", p2i(thr));
|
58 };
59
60 class VM_Handshake: public VM_Operation {
61 HandshakeThreadsOperation* const _op;
62 const jlong _handshake_timeout;
63 public:
64 bool evaluate_at_safepoint() const { return false; }
65
66 bool evaluate_concurrently() const { return false; }
67
68 protected:
69
70 VM_Handshake(HandshakeThreadsOperation* op) :
71 _op(op),
72 _handshake_timeout(TimeHelper::millis_to_counter(HandshakeTimeout)) {}
73
74 void set_handshake(JavaThread* target) {
75 target->set_handshake_operation(_op);
76 }
77
78 // This method returns true for threads completed their operation
79 // and true for threads canceled their operation.
80 // A cancellation can happen if the thread is exiting.
81 bool poll_for_completed_thread() { return _op->thread_has_completed(); }
82
83 bool handshake_has_timed_out(jlong start_time);
84 static void handle_timeout();
85 };
86
87 bool VM_Handshake::handshake_has_timed_out(jlong start_time) {
88 // Check if handshake operation has timed out
89 if (_handshake_timeout > 0) {
90 return os::elapsed_counter() >= (start_time + _handshake_timeout);
91 }
92 return false;
93 }
94
95 void VM_Handshake::handle_timeout() {
96 LogStreamHandle(Warning, handshake) log_stream;
97 MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
98 ALL_JAVA_THREADS(thr) {
99 if (thr->has_handshake()) {
100 log_stream.print("Thread " PTR_FORMAT " has not cleared its handshake op", p2i(thr));
|