Module: Synctest::Patches::ThreadPatch
- Defined in:
- lib/synctest/patches.rb
Instance Method Summary collapse
- #exit ⇒ Object
- #join(timeout = nil) ⇒ Object
- #kill ⇒ Object
- #raise(*arguments) ⇒ Object
- #run ⇒ Object
- #terminate ⇒ Object
- #value ⇒ Object
- #wakeup ⇒ Object
Instance Method Details
#exit ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/synctest/patches.rb', line 183 def exit if thread_variable_get(Synctest::THREAD_BUBBLE_KEY) || Synctest.bubble_for(self) bubble = Synctest.bubble_for_thread_operation(self) bubble.interrupt_thread(self) end super end |
#join(timeout = nil) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/synctest/patches.rb', line 127 def join(timeout = nil) owner = Synctest.bubble_for(self) bubble = owner ? Synctest.bubble_for_operation(self) : root_bubble_for_join return super unless bubble bubble.join(self, timeout) end |
#kill ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/synctest/patches.rb', line 167 def kill if thread_variable_get(Synctest::THREAD_BUBBLE_KEY) || Synctest.bubble_for(self) bubble = Synctest.bubble_for_thread_operation(self) bubble.interrupt_thread(self) end super end |
#raise(*arguments) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/synctest/patches.rb', line 191 def raise(*arguments) if thread_variable_get(Synctest::THREAD_BUBBLE_KEY) || Synctest.bubble_for(self) bubble = Synctest.bubble_for_thread_operation(self) bubble.interrupt_thread(self) end super end |
#run ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/synctest/patches.rb', line 159 def run bubble = Synctest.bubble_for_thread_operation(self) return super unless bubble return self if bubble.wake_thread(self) super end |
#terminate ⇒ Object
175 176 177 178 179 180 181 |
# File 'lib/synctest/patches.rb', line 175 def terminate if thread_variable_get(Synctest::THREAD_BUBBLE_KEY) || Synctest.bubble_for(self) bubble = Synctest.bubble_for_thread_operation(self) bubble.interrupt_thread(self) end super end |
#value ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/synctest/patches.rb', line 135 def value owner = Synctest.bubble_for(self) bubble = owner ? Synctest.bubble_for_operation(self) : root_bubble_for_join return super unless bubble unless owner if equal?(Thread.current) Kernel.raise ThreadError, "Target thread must not be current thread" end Kernel.raise UnsupportedOperationError, "Thread#value cannot target the root of its own Synctest bubble" end bubble.join(self, nil) Synctest::Raw::THREAD_VALUE.bind_call(self) end |
#wakeup ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/synctest/patches.rb', line 151 def wakeup bubble = Synctest.bubble_for_thread_operation(self) return super unless bubble return self if bubble.wake_thread(self) super end |