rsync

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCASConflict is returned when a CAS operation fails.
	ErrCASConflict = errors.New("CAS conflict")

	// ErrCASConflictTimeout is returned when a CAS operation fails
	// even after retrying.
	ErrCASConflictTimeout = errors.New("CAS conflict timeout")
)
View Source
var (
	// ErrMRSWConflict is returned when a MultiRSW operation fails.
	ErrMRSWConflict = errors.New("MRSW conflict")
)

Functions

This section is empty.

Types

type AtomicBool

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

AtomicBool is a boolean with atomic operations.

func NewAtomicBool

func NewAtomicBool() *AtomicBool

NewAtomicBool returns a new AtomicBool initialized to false.

func (*AtomicBool) Is

func (b *AtomicBool) Is() bool

Is returns true if the AtomicBool is true, false otherwise.

func (*AtomicBool) Set

func (b *AtomicBool) Set()

Set sets the AtomicBool to true.

func (*AtomicBool) Unset

func (b *AtomicBool) Unset()

Unset sets the AtomicBool to false.

type AtomicString

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

AtomicString is a string with atomic operations.

func NewAtomicString

func NewAtomicString() *AtomicString

NewAtomicString returns a new AtomicString.

func (*AtomicString) Load

func (s *AtomicString) Load() string

Load returns the stored string.

func (*AtomicString) Store

func (s *AtomicString) Store(newString string)

Store stores a new string.

type AtomicTime

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

AtomicTime is a time.Time with atomic operations.

func NewAtomicTime

func NewAtomicTime() *AtomicTime

NewAtomicTime returns a new AtomicTime.

func (*AtomicTime) Add

func (t *AtomicTime) Add(d time.Duration)

Add adds a duration to the stored time.

func (*AtomicTime) IsZero

func (t *AtomicTime) IsZero() bool

IsZero returns true if the stored time is zero, false otherwise.

func (*AtomicTime) Load

func (t *AtomicTime) Load() time.Time

Load returns the stored time.

func (*AtomicTime) Store

func (t *AtomicTime) Store(newTime time.Time)

Store stores a new time.

func (*AtomicTime) Sub

func (t *AtomicTime) Sub(tt *AtomicTime) time.Duration

Sub return the difference between the stored time and the given time.

type CheckAndSet

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

CheckAndSet is a simple concurrency control mechanism that allows only one goroutine to execute a critical section at a time.

func NewCheckAndSet

func NewCheckAndSet() *CheckAndSet

NewCheckAndSet creates a new CheckAndSet instance.

func (*CheckAndSet) Begin

func (c *CheckAndSet) Begin(owner string) error

Begin attempts to enter the critical section. If another goroutine is already in the critical section, Begin returns an error of type ErrCASConflict.

func (*CheckAndSet) BeginWithRetry

func (c *CheckAndSet) BeginWithRetry(owner string, timeout, retryInterval time.Duration) error

BeginWithRetry will attempt to enter the critical section, retrying if necessary.

func (*CheckAndSet) End

func (c *CheckAndSet) End()

End exits the critical section.

func (*CheckAndSet) Owner

func (c *CheckAndSet) Owner() string

Owner returns the current owner of the critical section.

func (*CheckAndSet) Stats

func (c *CheckAndSet) Stats() map[string]interface{}

Stats returns diagnostic information about the current state of the CheckAndSet instance.

type MultiRSW

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

MultiRSW is a simple concurrency control mechanism that allows multiple readers or a single writer to execute a critical section at a time.

func NewMultiRSW

func NewMultiRSW() *MultiRSW

NewMultiRSW creates a new MultiRSW instance.

func (*MultiRSW) BeginRead

func (r *MultiRSW) BeginRead() error

BeginRead attempts to enter the critical section as a reader.

func (*MultiRSW) BeginWrite

func (r *MultiRSW) BeginWrite() error

BeginWrite attempts to enter the critical section as a writer.

func (*MultiRSW) EndRead

func (r *MultiRSW) EndRead()

EndRead exits the critical section as a reader.

func (*MultiRSW) EndWrite

func (r *MultiRSW) EndWrite()

EndWrite exits the critical section as a writer.

func (*MultiRSW) UpgradeToWriter

func (r *MultiRSW) UpgradeToWriter() error

UpgradeToWriter attempts to upgrade a read lock to a write lock. The client must be the only reader in order to upgrade, and must already be in a read lock.

type Ordered

type Ordered interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64 | ~string
}

Ordered is a type that can be compared.

type PollTrue

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

PollTrue is a utility for polling a function until it returns true or a timeout is reached.

func NewPollTrue

func NewPollTrue(fn func() bool, pollInterval time.Duration, timeout time.Duration) *PollTrue

NewPollTrue creates a new PollTrue instance.

func (*PollTrue) Run

func (rt *PollTrue) Run(name string) error

Run polls the function until it returns true or the timeout is reached.

type ReadyChannels

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

ReadyChannels is a collection of channels that can be used to signal readiness.

func NewReadyChannels

func NewReadyChannels() *ReadyChannels

NewReadyChannels returns a new ReadyChannels.

func (*ReadyChannels) Ready

func (r *ReadyChannels) Ready() bool

Ready returns true if all registered channels have been closed.

func (*ReadyChannels) Register

func (r *ReadyChannels) Register(ch <-chan struct{})

Register registers a channel with the ReadyChannels. Until the given channel is closed, the ReadyChannels is not considered ready.

type ReadyTarget

type ReadyTarget[T Ordered] struct {
	// contains filtered or unexported fields
}

ReadyTarget is a mechanism whereby a target can be signalled as reached.

func NewReadyTarget

func NewReadyTarget[T Ordered]() *ReadyTarget[T]

NewReadyTarget returns a new ReadyTarget.

func (*ReadyTarget[T]) Len

func (r *ReadyTarget[T]) Len() int

Len returns the number of subscribers.

func (*ReadyTarget[T]) Reset

func (r *ReadyTarget[T]) Reset()

Reset resets the ReadyTarget back to the initial state, removing any subscribers.

func (*ReadyTarget[T]) Signal

func (r *ReadyTarget[T]) Signal(index T)

Signal informs the ReadyTarget that the given target has been reached. If the target is less than or equal to the current target, then the index is ignored.

func (*ReadyTarget[T]) Subscribe

func (r *ReadyTarget[T]) Subscribe(target T) <-chan struct{}

Subscribe returns a channel that will be closed when the target is reached. If the target has already been a reached the channel will be returned in a closed state.

func (*ReadyTarget[T]) Unsubscribe

func (r *ReadyTarget[T]) Unsubscribe(ch <-chan struct{})

Unsubscribe removes the subscription for the given target.

type Subscriber

type Subscriber[T Ordered] struct {
	// contains filtered or unexported fields
}

Subscriber is a subscription to notifications for a target being reached.

Jump to

Keyboard shortcuts

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