Documentation ¶
Overview ¶
Package semaphore provides an interface to named userspace semaphores.
Index ¶
- type Semaphore
- func (s *Semaphore) Close() error
- func (s *Semaphore) GetValue() (int, error)
- func (s *Semaphore) Open(name string, mode, value uint32) error
- func (s *Semaphore) Post() error
- func (s *Semaphore) TimedWait(d time.Duration) error
- func (s *Semaphore) TryWait() error
- func (s *Semaphore) Unlink() error
- func (s *Semaphore) Wait() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
func (*Semaphore) Close ¶
Close closes the named semaphore, allowing any resources that the system has allocated to the calling process for this semaphore to be freed.
func (*Semaphore) Open ¶
Open creates a new POSIX semaphore or opens an existing semaphore. The semaphore is identified by name. The mode argument specifies the permissions to be placed on the new semaphore. The value argument specifies the initial value for the new semaphore. If the named semaphore already exist, mode and value are ignored. For details see sem_overview(7).
func (*Semaphore) TimedWait ¶
TimedWait is the same as Wait(), except that d specifies a limit on the amount of time that the call should block if the decrement cannot be immediately performed.
func (*Semaphore) TryWait ¶
TryWait is the same as Wait(), except that if the decrement cannot be immediately performed, then the call returns an error instead of blocking.
func (*Semaphore) Unlink ¶
Unlink removes the named semaphore. The semaphore name is removed immediately. The semaphore is destroyed once all other processes that have the semaphore open close it.
func (*Semaphore) Wait ¶
Wait decrements the semaphore. If the semaphore's value is greater than zero, then the decrement proceeds, and the function returns, immediately. If the semaphore currently has the value zero, then the call blocks until either it becomes possible to perform the decrement, or a signal interrupts the call.