Flowdock
sync_try_lock_sub(m) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/sync.rb, line 262
  def sync_try_lock_sub(m)
    case m
    when SH
      case sync_mode
      when UN
        self.sync_mode = m
        sync_sh_locker[Thread.current] = 1
        ret = true
      when SH
        count = 0 unless count = sync_sh_locker[Thread.current]
        sync_sh_locker[Thread.current] = count + 1
        ret = true
      when EX
        # in EX mode, lock will upgrade to EX lock
        if sync_ex_locker == Thread.current
          self.sync_ex_count = sync_ex_count + 1
          ret = true
        else
          ret = false
        end
      end
    when EX
      if sync_mode == UN or
          sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
        self.sync_mode = m
        self.sync_ex_locker = Thread.current
        self.sync_ex_count = 1
        ret = true
      elsif sync_mode == EX && sync_ex_locker == Thread.current
        self.sync_ex_count = sync_ex_count + 1
        ret = true
      else
        ret = false
      end
    else
      Err::LockModeFailer.Fail mode
    end
    return ret
  end
Register or log in to add new notes.