{"modulePath":"github.com/g-node/gogs","version":"v0.11.91","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sync\n\n## Types\n\n```go\ntype ExclusivePool struct {\n\t// contains filtered or unexported fields\n}\n```\nExclusivePool 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.\n\nThis pool is particularly useful for performing tasks on same resource on the file system in different goroutines.\n\n```go\nfunc NewExclusivePool() *ExclusivePool\n```\nNewExclusivePool initializes and returns a new ExclusivePool object.\n\n```go\nfunc (p *ExclusivePool) CheckIn(identity string)\n```\nCheckIn checks in an instance to the pool and hangs while instance with same indentity is using the lock.\n\n```go\nfunc (p *ExclusivePool) CheckOut(identity string)\n```\nCheckOut checks out an instance from the pool and releases the lock to let other instances with same identity to grab the lock.\n\n```go\ntype StatusTable struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nStatusTable is a table maintains true/false values.\n\nThis table is particularly useful for un/marking and checking values in different goroutines.\n\n```go\nfunc NewStatusTable() *StatusTable\n```\nNewStatusTable initializes and returns a new StatusTable object.\n\n```go\nfunc (p *StatusTable) IsRunning(name string) bool\n```\nIsRunning checks if value of given name is set to true in the pool.\n\n```go\nfunc (p *StatusTable) Start(name string)\n```\nStart sets value of given name to true in the pool.\n\n```go\nfunc (p *StatusTable) Stop(name string)\n```\nStop sets value of given name to false in the pool.\n\n```go\ntype UniqueQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nUniqueQueue is a queue which guarantees only one instance of same identity is in the line. Instances with same identity will be discarded if there is already one in the line.\n\nThis queue is particularly useful for preventing duplicated task of same purpose.\n\n```go\nfunc NewUniqueQueue(queueLength int) *UniqueQueue\n```\nNewUniqueQueue initializes and returns a new UniqueQueue object.\n\n```go\nfunc (q *UniqueQueue) Add(id interface{})\n```\nAdd adds new instance to the queue.\n\n```go\nfunc (q *UniqueQueue) AddFunc(id interface{}, fn func())\n```\nAddFunc adds new instance to the queue with a custom runnable function, the queue is blocked until the function exits.\n\n```go\nfunc (q *UniqueQueue) Exist(id interface{}) bool\n```\nExist returns true if there is an instance with given indentity exists in the queue.\n\n```go\nfunc (q *UniqueQueue) Queue() \u003c-chan string\n```\nQueue returns channel of queue for retrieving instances.\n\n```go\nfunc (q *UniqueQueue) Remove(id interface{})\n```\nRemove removes instance from the queue.\n\n","path":"github.com/g-node/gogs/pkg/sync","name":"sync","synopsis":"","isRedistributable":true}
