Skip to content

Drop dependency on mutex_m #1013

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,77 @@ module Collection
# @!visibility private
class SynchronizedMapBackend < NonConcurrentMapBackend

require 'mutex_m'
include Mutex_m
# WARNING: Mutex_m is a non-reentrant lock, so the synchronized methods are
# not allowed to call each other.
def initialize(*args, &block)
super

# WARNING: Mutex is a non-reentrant lock, so the synchronized methods are
# not allowed to call each other.
@mutex = Mutex.new
end

def [](key)
synchronize { super }
@mutex.synchronize { super }
end

def []=(key, value)
synchronize { super }
@mutex.synchronize { super }
end

def compute_if_absent(key)
synchronize { super }
@mutex.synchronize { super }
end

def compute_if_present(key)
synchronize { super }
@mutex.synchronize { super }
end

def compute(key)
synchronize { super }
@mutex.synchronize { super }
end

def merge_pair(key, value)
synchronize { super }
@mutex.synchronize { super }
end

def replace_pair(key, old_value, new_value)
synchronize { super }
@mutex.synchronize { super }
end

def replace_if_exists(key, new_value)
synchronize { super }
@mutex.synchronize { super }
end

def get_and_set(key, value)
synchronize { super }
@mutex.synchronize { super }
end

def key?(key)
synchronize { super }
@mutex.synchronize { super }
end

def delete(key)
synchronize { super }
@mutex.synchronize { super }
end

def delete_pair(key, value)
synchronize { super }
@mutex.synchronize { super }
end

def clear
synchronize { super }
@mutex.synchronize { super }
end

def size
synchronize { super }
@mutex.synchronize { super }
end

def get_or_default(key, default_value)
synchronize { super }
@mutex.synchronize { super }
end

private
def dupped_backend
synchronize { super }
@mutex.synchronize { super }
end
end
end
Expand Down