Skip to content

Commit

Permalink
Make sure locks are not shared on shared when objects are dup/cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Jun 4, 2021
1 parent b57b483 commit 0ace358
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def initialize(*defaults)
@__Condition__ = ::ConditionVariable.new
end

def initialize_copy(other)
super
@__Lock__ = ::Mutex.new
@__Condition__ = ::ConditionVariable.new
end

protected

def synchronize
Expand Down Expand Up @@ -61,6 +67,12 @@ def initialize(*defaults)
@__Condition__ = @__Lock__.new_cond
end

def initialize_copy(other)
super
@__Lock__ = ::Mutex.new
@__Condition__ = @__Lock__.new_cond
end

protected

def synchronize # TODO may be a problem with lock.synchronize { lock.wait }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def initialize(*defaults)
@__owner__ = nil
end

def initialize_copy(other)
super
@__Waiters__ = []
@__owner__ = nil
end

protected

def synchronize(&block)
Expand Down

0 comments on commit 0ace358

Please sign in to comment.