public Method

Sync_m.sync_unlock(m = EX)

There's no documentation for this item.

Source Code

# File sync.rb, line 156
def sync_unlock(m = EX)
  Thread.critical = true
  if sync_mode == UN
    Thread.critical = false
    Err::UnknownLocker.Fail(Thread.current)
  end

  m = sync_mode if m == EX and sync_mode == SH

  runnable = false
  case m
  when UN
    Thread.critical = false
    Err::UnknownLocker.Fail(Thread.current)

  when EX
    if sync_ex_locker == Thread.current
      if (self.sync_ex_count = sync_ex_count - 1) == 0
        self.sync_ex_locker = nil
        if sync_sh_locker.include?(Thread.current)
          self.sync_mode = SH
        else
          self.sync_mode = UN
        end
        runnable = true
      end
    else
      Err::UnknownLocker.Fail(Thread.current)
    end

  when SH
    if (count = sync_sh_locker[Thread.current]).nil?
      Err::UnknownLocker.Fail(Thread.current)
    else
      if (sync_sh_locker[Thread.current] = count - 1) == 0 
        sync_sh_locker.delete(Thread.current)
        if sync_sh_locker.empty? and sync_ex_count == 0
          self.sync_mode = UN
          runnable = true
        end
      end
    end
  end

  if runnable
    if sync_upgrade_waiting.size > 0
      for k, v in sync_upgrade_waiting
        sync_sh_locker[k] = v
      end
      wait = sync_upgrade_waiting
      self.sync_upgrade_waiting = []
      Thread.critical = false

      for w, v in wait
        w.run
      end
    else
      wait = sync_waiting
      self.sync_waiting = []
      Thread.critical = false
      for w in wait
        w.run
      end
    end
  end

  Thread.critical = false
  self
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.