dbkit

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile

func AtomicWriteFile(path string, r io.Reader, mode os.FileMode) error

AtomicWriteFile reads from r and writes to the file named by path. To ensure atomicity the contents are written to a temporary file that is linked to the location after being successfully written.

Types

type Semaphore

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

Semaphore manages access to a resource using a set of tokens.

func NewSemaphore

func NewSemaphore(capacity int) *Semaphore

NewSemaphore will create and return a new semaphore.

func (*Semaphore) Acquire

func (s *Semaphore) Acquire(cancel <-chan struct{}, timeout time.Duration) bool

Acquire will acquire a token from the semaphore. If the function returns true the token must be released back to the semaphore exactly once.

func (*Semaphore) Release

func (s *Semaphore) Release()

Release will release a token to the semaphore. It is critical that this is only done once per token.

Jump to

Keyboard shortcuts

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