sync

package
v1.20.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 2 Imported by: 67

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExclusivePool

type ExclusivePool struct {
	// contains filtered or unexported fields
}

ExclusivePool is a pool of non-identical instances that only one instance with same identity is in the pool at a time. In other words, only instances with different identities can be in the pool the same time. If another instance with same identity tries to get into the pool, it hangs until previous instance left the pool.

This pool is particularly useful for performing tasks on same resource on the file system in different goroutines.

func NewExclusivePool

func NewExclusivePool() *ExclusivePool

NewExclusivePool initializes and returns a new ExclusivePool object.

func (*ExclusivePool) CheckIn

func (p *ExclusivePool) CheckIn(identity string)

CheckIn checks in an instance to the pool and hangs while instance with same identity is using the lock.

func (*ExclusivePool) CheckOut

func (p *ExclusivePool) CheckOut(identity string)

CheckOut checks out an instance from the pool and releases the lock to let other instances with same identity to grab the lock.

type StatusTable

type StatusTable struct {
	// contains filtered or unexported fields
}

StatusTable is a table maintains true/false values.

This table is particularly useful for un/marking and checking values in different goroutines.

func NewStatusTable

func NewStatusTable() *StatusTable

NewStatusTable initializes and returns a new StatusTable object.

func (*StatusTable) IsRunning

func (p *StatusTable) IsRunning(name string) bool

IsRunning checks if value of given name is set to true in the pool.

func (*StatusTable) Start

func (p *StatusTable) Start(name string)

Start sets value of given name to true in the pool.

func (*StatusTable) StartIfNotRunning added in v1.2.0

func (p *StatusTable) StartIfNotRunning(name string) bool

StartIfNotRunning sets value of given name to true if not already in pool. Returns whether set value was set to true

func (*StatusTable) Stop

func (p *StatusTable) Stop(name string)

Stop sets value of given name to false in the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL