< prev index next >
src/hotspot/share/runtime/handshake.hpp
Print this page
rev 57079 : [mq]: handshake-logs
@@ -27,27 +27,45 @@
#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 HandshakeOperation: public StackObj {
+ static Semaphore _done;
+ bool _executed;
+public:
+ HandshakeOperation() : _executed(false) {}
+
+ void do_handshake(JavaThread* thread);
+ bool thread_has_completed() { return _done.trywait(); }
+ bool executed() const { return _executed; }
+
+#ifdef ASSERT
+ void check_state() {
+ assert(!_done.trywait(), "Must be zero");
+ }
+#endif
+
+ // Impl
+ virtual void do_thread(JavaThread* thread) = 0;
+ virtual const char* name() = 0;
+};
+
class Handshake : public AllStatic {
public:
// Execution of handshake operation
- static void execute(ThreadClosure* thread_cl);
- static bool execute(ThreadClosure* thread_cl, JavaThread* target);
+ static void execute(HandshakeOperation* hs_op);
+ static bool execute(HandshakeOperation* hs_op, 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 {
@@ -76,9 +94,9 @@
FlagSetting fs(_thread_in_process_handshake, true);
process_self_inner(thread);
}
}
- void process_by_vmthread(JavaThread* target);
+ bool process_by_vmthread(JavaThread* target);
};
#endif // SHARE_RUNTIME_HANDSHAKE_HPP
< prev index next >