Class: Lockfile::Lockfile

Inherits:
Object
  • Object
show all
Defined in:
lib/scout/open/lock/lockfile.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debugObject

Returns the value of attribute debug.



87
88
89
# File 'lib/scout/open/lock/lockfile.rb', line 87

def debug
  @debug
end

.dont_cleanObject

Returns the value of attribute dont_clean.



88
89
90
# File 'lib/scout/open/lock/lockfile.rb', line 88

def dont_clean
  @dont_clean
end

.dont_sweepObject

Returns the value of attribute dont_sweep.



91
92
93
# File 'lib/scout/open/lock/lockfile.rb', line 91

def dont_sweep
  @dont_sweep
end

.dont_use_lock_idObject

Returns the value of attribute dont_use_lock_id.



92
93
94
# File 'lib/scout/open/lock/lockfile.rb', line 92

def dont_use_lock_id
  @dont_use_lock_id
end

.max_ageObject

Returns the value of attribute max_age.



80
81
82
# File 'lib/scout/open/lock/lockfile.rb', line 80

def max_age
  @max_age
end

.max_sleepObject

Returns the value of attribute max_sleep.



83
84
85
# File 'lib/scout/open/lock/lockfile.rb', line 83

def max_sleep
  @max_sleep
end

.min_sleepObject

Returns the value of attribute min_sleep.



82
83
84
# File 'lib/scout/open/lock/lockfile.rb', line 82

def min_sleep
  @min_sleep
end

.poll_max_sleepObject

Returns the value of attribute poll_max_sleep.



90
91
92
# File 'lib/scout/open/lock/lockfile.rb', line 90

def poll_max_sleep
  @poll_max_sleep
end

.poll_retriesObject

Returns the value of attribute poll_retries.



89
90
91
# File 'lib/scout/open/lock/lockfile.rb', line 89

def poll_retries
  @poll_retries
end

.refreshObject

Returns the value of attribute refresh.



86
87
88
# File 'lib/scout/open/lock/lockfile.rb', line 86

def refresh
  @refresh
end

.retriesObject

Returns the value of attribute retries.



79
80
81
# File 'lib/scout/open/lock/lockfile.rb', line 79

def retries
  @retries
end

.sleep_incObject

Returns the value of attribute sleep_inc.



81
82
83
# File 'lib/scout/open/lock/lockfile.rb', line 81

def sleep_inc
  @sleep_inc
end

.suspendObject

Returns the value of attribute suspend.



84
85
86
# File 'lib/scout/open/lock/lockfile.rb', line 84

def suspend
  @suspend
end

.timeoutObject

Returns the value of attribute timeout.



85
86
87
# File 'lib/scout/open/lock/lockfile.rb', line 85

def timeout
  @timeout
end

Class Method Details

.create(path, *a, &b) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/scout/open/lock/lockfile.rb', line 147

def Lockfile.create(path, *a, &b)
  opts = {
    'retries' => 0,
    'min_sleep' => 0,
    'max_sleep' => 1,
    'sleep_inc' => 1,
    'max_age' => nil,
    'suspend' => 0,
    'refresh' => nil,
    'timeout' => nil,
    'poll_retries' => 0,
    'dont_clean' => true,
    'dont_sweep' => false,
    'dont_use_lock_id' => true,
  }
  begin
    new(path, opts).lock
  rescue LockError
    raise Errno::EEXIST, path
  end
  open(path, *a, &b)
end

.initObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/scout/open/lock/lockfile.rb', line 94

def init
  @retries          = DEFAULT_RETRIES
  @max_age          = DEFAULT_MAX_AGE
  @sleep_inc        = DEFAULT_SLEEP_INC
  @min_sleep        = DEFAULT_MIN_SLEEP
  @max_sleep        = DEFAULT_MAX_SLEEP
  @suspend          = DEFAULT_SUSPEND
  @timeout          = DEFAULT_TIMEOUT
  @refresh          = DEFAULT_REFRESH
  @dont_clean       = DEFAULT_DONT_CLEAN
  @poll_retries     = DEFAULT_POLL_RETRIES
  @poll_max_sleep   = DEFAULT_POLL_MAX_SLEEP
  @dont_sweep       = DEFAULT_DONT_SWEEP
  @dont_use_lock_id = DEFAULT_DONT_USE_LOCK_ID

  @debug          = DEFAULT_DEBUG

  STDOUT.sync = true if @debug
  STDERR.sync = true if @debug
end