Skip to content

Commit

Permalink
Fix problem with circular type reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Oct 22, 2015
1 parent e1eb829 commit f1cb675
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ReadWriteLocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ if !isdefined(Base, :Mutex)
unlock!(x::Mutex) = unlock(x)
end

type ReadWriteLock
abstract _Lock

immutable ReadLock{T<:_Lock}
rwlock::T
end

immutable WriteLock{T<:_Lock}
rwlock::T
end

type ReadWriteLock <: _Lock
readers::Int
writer::Bool
lock::Mutex # reentrant mutex
Expand All @@ -37,10 +47,6 @@ end
read_lock(rwlock::ReadWriteLock) = rwlock.read_lock
write_lock(rwlock::ReadWriteLock) = rwlock.write_lock

immutable ReadLock
rwlock::ReadWriteLock
end

function lock!(read_lock::ReadLock)
rwlock = read_lock.rwlock
lock!(rwlock.lock)
Expand Down Expand Up @@ -74,10 +80,6 @@ function unlock!(read_lock::ReadLock)
return nothing
end

immutable WriteLock
rwlock::ReadWriteLock
end

function lock!(write_lock::WriteLock)
rwlock = write_lock.rwlock
lock!(rwlock.lock)
Expand Down

0 comments on commit f1cb675

Please sign in to comment.