4 Matching Annotations
- Sep 2024
-
en.wikipedia.org en.wikipedia.org
-
The complication comes from the fact that the execution model does not have any means for the execution of "give up ownership of the lock" to have any influence over which execution of "gain ownership of the lock" in some other timeline (thread) follows. Very often, only certain handoffs give valid results. Thus, the programmer must think of all possible combinations of one thread giving up a lock and another thread getting it next, and make sure their code only allows valid combinations.
-
- Nov 2023
-
github.com github.com
-
Otherwise, M does not respond to works? (NoMethodError) because there was a context switch before the require triggered by autoload returned.
-
If it passed before I would think it was just lucky timings.
-
BTW to improve the reliability of that test I believe you would need a sleep (smaller, e.g. of 0.1) between the Thread.new and assert M.works?, otherwise it's likely the M.works? runs first and then the other thread will see the constant is autoloading and wait, and anyway that thread does not check what is defined on M. For the test to fail it needs to be the Thread.new running first and defining the constant but not yet the method, before the main thread keeps running and call the method.
-