< prev index next >

src/hotspot/share/runtime/handshake.hpp

Print this page
rev 57079 : imported patch 8234796

*** 27,53 **** #include "memory/allocation.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/semaphore.hpp" - class ThreadClosure; class JavaThread; // A handshake operation is a callback that is executed for each JavaThread // while that thread is in a safepoint safe state. The callback is executed // either by the thread itself or by the VM thread while keeping the thread // in a blocked state. A handshake can be performed with a single // JavaThread as well. class Handshake : public AllStatic { public: // Execution of handshake operation ! static void execute(ThreadClosure* thread_cl); ! static bool execute(ThreadClosure* thread_cl, JavaThread* target); }; - class HandshakeOperation; - // The HandshakeState keep tracks of an ongoing handshake for one JavaThread. // VM thread and JavaThread are serialized with the semaphore making sure // the operation is only done by either VM thread on behalf of the JavaThread // or the JavaThread itself. class HandshakeState { --- 27,72 ---- #include "memory/allocation.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/semaphore.hpp" class JavaThread; // A handshake operation is a callback that is executed for each JavaThread // while that thread is in a safepoint safe state. The callback is executed // either by the thread itself or by the VM thread while keeping the thread // in a blocked state. A handshake can be performed with a single // JavaThread as well. + class HandshakeOperation: public StackObj { + static Semaphore _done; + const char* _name; + bool _executed; + public: + HandshakeOperation(const char* name) : _name(name), _executed(false) {} + + void do_handshake(JavaThread* thread); + bool thread_has_completed() { return _done.trywait(); } + bool executed() const { return _executed; } + const char* name() { return _name; }; + + #ifdef ASSERT + void check_state() { + assert(!_done.trywait(), "Must be zero"); + } + #endif + + // Impl + virtual void do_thread(JavaThread* thread) = 0; + }; + class Handshake : public AllStatic { public: // Execution of handshake operation ! static void execute(HandshakeOperation* hs_op); ! static bool execute(HandshakeOperation* hs_op, JavaThread* target); }; // The HandshakeState keep tracks of an ongoing handshake for one JavaThread. // VM thread and JavaThread are serialized with the semaphore making sure // the operation is only done by either VM thread on behalf of the JavaThread // or the JavaThread itself. class HandshakeState {
< prev index next >