Class: CountingSemaphore::Lease

Inherits:
Struct
  • Object
show all
Defined in:
lib/counting_semaphore.rb

Overview

Represents an acquired lease on a semaphore. Must be passed to release() to return the permits.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#id ⇒ Object

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



8
9
10
# File 'lib/counting_semaphore.rb', line 8

def id
  @id
end

#permits ⇒ Object

Returns the value of attribute permits

Returns:

  • (Object) —

    the current value of permits



8
9
10
# File 'lib/counting_semaphore.rb', line 8

def permits
  @permits
end

#semaphore ⇒ Object

Returns the value of attribute semaphore

Returns:

  • (Object) —

    the current value of semaphore



8
9
10
# File 'lib/counting_semaphore.rb', line 8

def semaphore
  @semaphore
end

Instance Method Details

#inspect ⇒ String

Returns detailed inspection string

Returns:

  • (String)


19
20
21
# File 'lib/counting_semaphore.rb', line 19

def inspect
  "#<CountingSemaphore::Lease permits=#{permits} id=#{id.inspect}>"
end

#to_s ⇒ String

Returns a human-readable representation of the lease

Returns:

  • (String)


12
13
14
# File 'lib/counting_semaphore.rb', line 12

def to_s
  "Lease(#{permits} permits, id: #{id})"
end