Class: Lockfile::Lockfile
- Inherits:
-
Object
- Object
- Lockfile::Lockfile
- Defined in:
- lib/scout/open/lock/lockfile.rb
Class Attribute Summary collapse
-
.debug ⇒ Object
Returns the value of attribute debug.
-
.dont_clean ⇒ Object
Returns the value of attribute dont_clean.
-
.dont_sweep ⇒ Object
Returns the value of attribute dont_sweep.
-
.dont_use_lock_id ⇒ Object
Returns the value of attribute dont_use_lock_id.
-
.max_age ⇒ Object
Returns the value of attribute max_age.
-
.max_sleep ⇒ Object
Returns the value of attribute max_sleep.
-
.min_sleep ⇒ Object
Returns the value of attribute min_sleep.
-
.poll_max_sleep ⇒ Object
Returns the value of attribute poll_max_sleep.
-
.poll_retries ⇒ Object
Returns the value of attribute poll_retries.
-
.refresh ⇒ Object
Returns the value of attribute refresh.
-
.retries ⇒ Object
Returns the value of attribute retries.
-
.sleep_inc ⇒ Object
Returns the value of attribute sleep_inc.
-
.suspend ⇒ Object
Returns the value of attribute suspend.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Class Attribute Details
.debug ⇒ Object
Returns the value of attribute debug.
87 88 89 |
# File 'lib/scout/open/lock/lockfile.rb', line 87 def debug @debug end |
.dont_clean ⇒ Object
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_sweep ⇒ Object
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_id ⇒ Object
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_age ⇒ Object
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_sleep ⇒ Object
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_sleep ⇒ Object
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_sleep ⇒ Object
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_retries ⇒ Object
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 |
.refresh ⇒ Object
Returns the value of attribute refresh.
86 87 88 |
# File 'lib/scout/open/lock/lockfile.rb', line 86 def refresh @refresh end |
.retries ⇒ Object
Returns the value of attribute retries.
79 80 81 |
# File 'lib/scout/open/lock/lockfile.rb', line 79 def retries @retries end |
.sleep_inc ⇒ Object
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 |
.suspend ⇒ Object
Returns the value of attribute suspend.
84 85 86 |
# File 'lib/scout/open/lock/lockfile.rb', line 84 def suspend @suspend end |
.timeout ⇒ Object
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 |
.init ⇒ Object
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 |