diff options
author | Yusuke Endoh <[email protected]> | 2022-07-22 16:49:08 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2022-07-22 23:10:24 +0900 |
commit | e763b1118ba1fada81d37da558f9d8e4da99f144 (patch) | |
tree | 2e1c85e7879eccbe211169a8510bc916ecba83f1 /ractor_core.h | |
parent | c7fd015d83740b3e758796f8c7d85cc64602f371 (diff) |
Move enum definitions out of struct definition
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6169
Diffstat (limited to 'ractor_core.h')
-rw-r--r-- | ractor_core.h | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/ractor_core.h b/ractor_core.h index dd1b73b331..b35a59e9c5 100644 --- a/ractor_core.h +++ b/ractor_core.h @@ -40,6 +40,24 @@ struct rb_ractor_waiting_list { rb_ractor_t **ractors; }; +enum ractor_wait_status { + wait_none = 0x00, + wait_receiving = 0x01, + wait_taking = 0x02, + wait_yielding = 0x04, + wait_moving = 0x08, +}; + +enum ractor_wakeup_status { + wakeup_none, + wakeup_by_send, + wakeup_by_yield, + wakeup_by_take, + wakeup_by_close, + wakeup_by_interrupt, + wakeup_by_retry, +}; + struct rb_ractor_sync { // ractor lock rb_nativethread_lock_t lock; @@ -56,29 +74,34 @@ struct rb_ractor_sync { bool outgoing_port_closed; struct ractor_wait { - enum ractor_wait_status { - wait_none = 0x00, - wait_receiving = 0x01, - wait_taking = 0x02, - wait_yielding = 0x04, - wait_moving = 0x08, - } status; - - enum ractor_wakeup_status { - wakeup_none, - wakeup_by_send, - wakeup_by_yield, - wakeup_by_take, - wakeup_by_close, - wakeup_by_interrupt, - wakeup_by_retry, - } wakeup_status; - + enum ractor_wait_status status; + enum ractor_wakeup_status wakeup_status; struct rb_ractor_basket yielded_basket; struct rb_ractor_basket taken_basket; } wait; }; +// created +// | ready to run +// ====================== inserted to vm->ractor +// v +// blocking <---+ all threads are blocking +// | | +// v | +// running -----+ +// | all threads are terminated. +// ====================== removed from vm->ractor +// v +// terminated +// +// status is protected by VM lock (global state) +enum ractor_status { + ractor_created, + ractor_running, + ractor_blocking, + ractor_terminated, +}; + struct rb_ractor_struct { struct rb_ractor_pub pub; @@ -104,27 +127,7 @@ struct rb_ractor_struct { VALUE name; VALUE loc; - // created - // | ready to run - // ====================== inserted to vm->ractor - // v - // blocking <---+ all threads are blocking - // | | - // v | - // running -----+ - // | all threads are terminated. - // ====================== removed from vm->ractor - // v - // terminated - // - // status is protected by VM lock (global state) - - enum ractor_status { - ractor_created, - ractor_running, - ractor_blocking, - ractor_terminated, - } status_; + enum ractor_status status_; struct ccan_list_node vmlr_node; |