Class: Qonfig::Settings::Lock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/qonfig/settings/lock.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0

Instance Method Summary collapse

Constructor Details

#initializeLock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Lock.

Since:

  • 0.2.0



8
9
10
11
12
# File 'lib/qonfig/settings/lock.rb', line 8

def initialize
  @definition_lock = Mutex.new
  @access_lock = Mutex.new
  @merge_lock = Mutex.new
end

Instance Method Details

#thread_safe_access(&instructions) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • instructions (Proc)

Returns:

  • (Object)

Since:

  • 0.2.0



28
29
30
# File 'lib/qonfig/settings/lock.rb', line 28

def thread_safe_access(&instructions)
  access_lock.owned? ? yield : access_lock.synchronize(&instructions)
end

#thread_safe_definition(&instructions) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • instructions (Proc)

Returns:

  • (Object)

Since:

  • 0.2.0



19
20
21
# File 'lib/qonfig/settings/lock.rb', line 19

def thread_safe_definition(&instructions)
  definition_lock.owned? ? yield : definition_lock.synchronize(&instructions)
end

#thread_safe_merge(&instructions) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • instructions (Proc)

Returns:

  • (Object)

Since:

  • 0.2.0



37
38
39
# File 'lib/qonfig/settings/lock.rb', line 37

def thread_safe_merge(&instructions)
  merge_lock.owned? ? yield : merge_lock.synchronize(&instructions)
end