-
-
Notifications
You must be signed in to change notification settings - Fork 102
Use Fiber.current
for current execution context. Fixes #501.
#502
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'fiber' | ||
|
||
module RSpec | ||
module Support | ||
# Allows a thread to lock out other threads from a critical section of code, | ||
|
@@ -28,8 +30,8 @@ def synchronize | |
private | ||
|
||
def enter | ||
@mutex.lock if @owner != Thread.current | ||
@owner = Thread.current | ||
ioquatix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@mutex.lock if @owner != Fiber.current | ||
@owner = Fiber.current | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT of def current
defined?(Fiber.current) ? Fiber.current : Thread.current
end and using it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's broken. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whenever some file would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For sure. I hope they don't do it dynamically when there are existing fibers and reentrant mutexes in action. Otherwise - do you see any issue? Ok, let's put it another way. I couldn't find any mention of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this not break in a more typical threaded solution? E.g. JRuby There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think it's advisable to take that risk/assumption, and anyway AFAIK there is no need. |
||
@count += 1 | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I foresee that @JonRowe would say that requiring a dependency from stdlib is something that we try to avoid at all costs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we don't require things that developers need to require because it causes weird failures for developers. (e.g. RSpec will pass because we require it but it won't work in dev/production).