Class: ProcessShared::Mach::Semaphore
- Inherits:
-
Mach::Semaphore
- Object
- Mach::Port
- Mach::Semaphore
- ProcessShared::Mach::Semaphore
- Extended by:
- OpenWithSelf
- Includes:
- SynchronizableSemaphore
- Defined in:
- lib/process_shared/mach/semaphore.rb
Overview
Extends ::Mach::Semaphore to be compatible with ProcessShared::Semaphore
Instance Attribute Summary
Attributes inherited from Mach::Port
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(value = 1) ⇒ Semaphore
constructor
A new instance of Semaphore.
- #try_wait(timeout = nil) ⇒ Object
- #value ⇒ Object
Methods included from OpenWithSelf
Methods included from SynchronizableSemaphore
Methods inherited from Mach::Semaphore
#destroy, #signal, #signal_all, #timedwait, #wait
Methods included from Mach::Functions
attach_mach_function, error_check, error_check_bootstrap, new_memory_pointer, #new_memory_pointer
Methods included from Mach::Types
Methods inherited from Mach::Port
#==, #copy_send, #deallocate, #destroy, #insert_right, #receive_right, #send_right, #to_s
Constructor Details
#initialize(value = 1) ⇒ Semaphore
Returns a new instance of Semaphore.
15 16 17 18 |
# File 'lib/process_shared/mach/semaphore.rb', line 15 def initialize(value = 1) super(:value => value) ProcessShared::Mach.shared_ports.add self end |
Instance Method Details
#close ⇒ Object
37 38 39 |
# File 'lib/process_shared/mach/semaphore.rb', line 37 def close # TODO end |
#try_wait(timeout = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/process_shared/mach/semaphore.rb', line 20 def try_wait(timeout = nil) secs = timeout ? timeout : 0 begin # TODO catch and convert exceptions... timedwait(secs) rescue Mach::Error::OPERATION_TIMED_OUT => e klass = secs == 0 ? Errno::EAGAIN : Errno::ETIMEDOUT raise klass, e. end end |
#value ⇒ Object
33 34 35 |
# File 'lib/process_shared/mach/semaphore.rb', line 33 def value raise Errno::ENOTSUP end |