Index: runtime/vm/isolate.h |
=================================================================== |
--- runtime/vm/isolate.h (revision 21380) |
+++ runtime/vm/isolate.h (working copy) |
@@ -273,6 +273,11 @@ |
kVmStatusInterrupt, |
}; |
+ enum IsolateRunState { |
+ kIsolateWaiting = 0, // The isolate is waiting for code to execute. |
+ kIsolateRunning, // The isolate is executing code. |
+ }; |
+ |
void ScheduleInterrupts(uword interrupt_bits); |
uword GetAndClearInterrupts(); |
@@ -285,6 +290,9 @@ |
bool is_runnable() const { return is_runnable_; } |
void set_is_runnable(bool value) { is_runnable_ = value; } |
+ IsolateRunState running_state() const { return running_state_; } |
+ void set_running_state(IsolateRunState value) { running_state_ = value; } |
+ |
uword spawn_data() const { return spawn_data_; } |
void set_spawn_data(uword value) { spawn_data_ = value; } |
@@ -492,6 +500,7 @@ |
MessageHandler* message_handler_; |
uword spawn_data_; |
bool is_runnable_; |
+ IsolateRunState running_state_; |
GcPrologueCallbacks gc_prologue_callbacks_; |
GcEpilogueCallbacks gc_epilogue_callbacks_; |
@@ -607,6 +616,29 @@ |
char* exception_callback_name_; |
}; |
+ |
+class IsolateRunStateManager : public StackResource { |
+ public: |
+ explicit IsolateRunStateManager() |
+ : StackResource(Isolate::Current()), |
+ saved_state_(Isolate::kIsolateWaiting) { |
+ saved_state_ = reinterpret_cast<Isolate*>(isolate())->running_state(); |
+ } |
+ |
+ virtual ~IsolateRunStateManager() { |
+ reinterpret_cast<Isolate*>(isolate())->set_running_state(saved_state_); |
+ } |
+ |
+ void SetRunState(Isolate::IsolateRunState run_state) { |
+ reinterpret_cast<Isolate*>(isolate())->set_running_state(run_state); |
+ } |
+ |
+ private: |
+ Isolate::IsolateRunState saved_state_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IsolateRunStateManager); |
+}; |
+ |
} // namespace dart |
#endif // VM_ISOLATE_H_ |