Documentation ¶
Index ¶
- Variables
- type SHMLocks
- func (locks *SHMLocks) AllocateGivenSemaphore(sem uint32) error
- func (locks *SHMLocks) AllocateSemaphore() (uint32, error)
- func (locks *SHMLocks) Close() error
- func (locks *SHMLocks) DeallocateAllSemaphores() error
- func (locks *SHMLocks) DeallocateSemaphore(sem uint32) error
- func (locks *SHMLocks) GetMaxLocks() uint32
- func (locks *SHMLocks) LockSemaphore(sem uint32) error
- func (locks *SHMLocks) UnlockSemaphore(sem uint32) error
Constants ¶
This section is empty.
Variables ¶
var ( // BitmapSize is the size of the bitmap used when managing SHM locks. // an SHM lock manager's max locks will be rounded up to a multiple of // this number. BitmapSize uint32 = uint32(C.bitmap_size_c) )
Functions ¶
This section is empty.
Types ¶
type SHMLocks ¶
type SHMLocks struct {
// contains filtered or unexported fields
}
SHMLocks is a struct enabling POSIX semaphore locking in a shared memory segment.
func CreateSHMLock ¶
CreateSHMLock sets up a shared-memory segment holding a given number of POSIX semaphores, and returns a struct that can be used to operate on those locks. numLocks must not be 0, and may be rounded up to a multiple of the bitmap size used by the underlying implementation.
func OpenSHMLock ¶
OpenSHMLock opens an existing shared-memory segment holding a given number of POSIX semaphores. numLocks must match the number of locks the shared memory segment was created with.
func (*SHMLocks) AllocateGivenSemaphore ¶ added in v1.3.1
AllocateGivenSemaphore allocates the given semaphore from the shared-memory segment for use by a container or pod. If the semaphore is already in use or the index is invalid an error will be returned.
func (*SHMLocks) AllocateSemaphore ¶
AllocateSemaphore allocates a semaphore from a shared-memory segment for use by a container or pod. Returns the index of the semaphore that was allocated. Allocations past the maximum number of locks given when the SHM segment was created will result in an error, and no semaphore will be allocated.
func (*SHMLocks) Close ¶
Close closes an existing shared-memory segment. The segment will be rendered unusable after closing. WARNING: If you Close() while there are still locks locked, these locks may fail to release, causing a program freeze. Close() is only intended to be used while testing the locks.
func (*SHMLocks) DeallocateAllSemaphores ¶
DeallocateAllSemaphores frees all semaphores so they can be reallocated to other containers and pods.
func (*SHMLocks) DeallocateSemaphore ¶
DeallocateSemaphore frees a semaphore in a shared-memory segment so it can be reallocated to another container or pod. The given semaphore must be already allocated, or an error will be returned.
func (*SHMLocks) GetMaxLocks ¶
GetMaxLocks returns the maximum number of locks in the SHM
func (*SHMLocks) LockSemaphore ¶
LockSemaphore locks the given semaphore. If the semaphore is already locked, LockSemaphore will block until the lock can be acquired. There is no requirement that the given semaphore be allocated. This ensures that attempts to lock a container after it has been deleted, but before the caller has queried the database to determine this, will succeed.
func (*SHMLocks) UnlockSemaphore ¶
UnlockSemaphore unlocks the given semaphore. Unlocking a semaphore that is already unlocked with return EBUSY. There is no requirement that the given semaphore be allocated. This ensures that attempts to lock a container after it has been deleted, but before the caller has queried the database to determine this, will succeed.