Add LockBehavior to semaphore spec.
This commit is contained in:
parent
5dc3c7299e
commit
d012a11237
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
require 'process_shared'
|
||||
|
||||
require 'process_shared/lock_behavior'
|
||||
|
||||
module ProcessShared
|
||||
describe Mutex do
|
||||
|
||||
|
|
|
@ -5,6 +5,25 @@ require 'process_shared'
|
|||
|
||||
module ProcessShared
|
||||
describe Semaphore do
|
||||
|
||||
describe 'As Lock' do
|
||||
|
||||
include LockBehavior
|
||||
|
||||
before :each do
|
||||
@lock = Semaphore.new
|
||||
class << @lock
|
||||
alias_method :lock, :wait
|
||||
alias_method :unlock, :post
|
||||
end
|
||||
end
|
||||
|
||||
after :each do
|
||||
@lock.close
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'coordinates access to shared object' do
|
||||
nprocs = 4 # number of processes
|
||||
nincrs = 1000 # each process increments nincrs times
|
||||
|
|
|
@ -5,6 +5,7 @@ require 'minitest/autorun'
|
|||
require 'minitest/matchers'
|
||||
|
||||
require 'process_shared'
|
||||
require 'process_shared/lock_behavior'
|
||||
|
||||
class RangeMatcher
|
||||
def initialize(operator, limit)
|
||||
|
|
Loading…
Reference in New Issue