Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BlockingFlag needs to provide an interface to synchronize mutex #13

Open
frsyuki opened this issue Dec 24, 2013 · 0 comments
Open

BlockingFlag needs to provide an interface to synchronize mutex #13

frsyuki opened this issue Dec 24, 2013 · 0 comments

Comments

@frsyuki
Copy link
Member

frsyuki commented Dec 24, 2013

This code has race condition:

while true
  do_something
  if blocking_flag.set?
    # here
    blocking_flag.wait_for_set
  end
end

because "here" does not acquire mutex. It should be like this:

while true
  do_something
  blocking_flag.synchronize do
    if blocking_flag.set?
      # here
      blocking_flag.wait_for_set
    end
  end
end

Thus BlockingFlag#synchronize(&block) or similar interface is necessary.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant