basic

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidTaskResult = &struct{}{}
	DummyTaskResult   = struct{}{}
)

Functions

This section is empty.

Types

type AtomicBool

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

AtomicBool gives an atomic boolean variable.

func NewAtomicBool

func NewAtomicBool(n bool) AtomicBool

NewAtomicBool initializes a new AtomicBool with a given value.

func (*AtomicBool) CompareAndSwap

func (i *AtomicBool) CompareAndSwap(o, n bool) bool

CompareAndSwap automatically swaps the old with the new value.

func (*AtomicBool) Get

func (i *AtomicBool) Get() bool

Get atomically returns the current value.

func (*AtomicBool) Set

func (i *AtomicBool) Set(n bool)

Set atomically sets n as new value.

type AtomicInt32

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

AtomicInt32 is a wrapper with a simpler interface around atomic.(Add|Store|Load|CompareAndSwap)Int32 functions.

func NewAtomicInt32

func NewAtomicInt32(n int32) AtomicInt32

NewAtomicInt32 initializes a new AtomicInt32 with a given value.

func (*AtomicInt32) Add

func (i *AtomicInt32) Add(n int32) int32

Add atomically adds n to the value.

func (*AtomicInt32) CompareAndSwap

func (i *AtomicInt32) CompareAndSwap(oldVal, newVal int32) (swapped bool)

CompareAndSwap automatically swaps the old with the new value.

func (*AtomicInt32) Get

func (i *AtomicInt32) Get() int32

Get atomically returns the current value.

func (*AtomicInt32) Set

func (i *AtomicInt32) Set(n int32)

Set atomically sets n as new value.

type AtomicUint64

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

AtomicUint64 is a wrapper with a simpler interface around atomic.(Add|Store|Load|CompareAndSwap)Uint64 functions.

func NewAtomicUint64

func NewAtomicUint64(n uint64) AtomicUint64

NewAtomicUint64 initializes a new AtomicUint64 with a given value.

func (*AtomicUint64) Add

func (i *AtomicUint64) Add(n uint64) uint64

Add atomically adds n to the value.

func (*AtomicUint64) CompareAndSwap

func (i *AtomicUint64) CompareAndSwap(oldVal, newVal uint64) (swapped bool)

CompareAndSwap automatically swaps the old with the new value.

func (*AtomicUint64) Get

func (i *AtomicUint64) Get() uint64

Get atomically returns the current value.

func (*AtomicUint64) Set

func (i *AtomicUint64) Set(n uint64)

Set atomically sets n as new value.

type Set

type Set map[string]struct{}

func MakeSet

func MakeSet(keys []string) Set

func (Set) Contains

func (s Set) Contains(key string) bool

func (*Set) Insert

func (s *Set) Insert(key string)

func (Set) InsertUnsafe

func (s Set) InsertUnsafe(key string)

func (Set) MustFirst

func (s Set) MustFirst() string

func (*Set) Reset

func (s *Set) Reset()

type Task

type Task struct {
	ID   TaskId
	Name string

	Data interface{}
	// contains filtered or unexported fields
}

func NewTask

func NewTask(id TaskId, name string, runTimeout time.Duration, f func(context.Context) (interface{}, error)) *Task

func NewTaskNoResult

func NewTaskNoResult(id TaskId, name string, runTimeout time.Duration, g func(context.Context) error) *Task

func (*Task) Cancel

func (t *Task) Cancel()

func (*Task) Err

func (t *Task) Err() error

func (*Task) ErrUnsafe

func (t *Task) ErrUnsafe() error

func (*Task) Finished

func (t *Task) Finished() bool

func (*Task) Initialize

func (t *Task) Initialize(id TaskId, name string, runTimeout time.Duration, f func(context.Context) (interface{}, error)) *Task

func (*Task) MustWaitFinishWithContext

func (t *Task) MustWaitFinishWithContext(ctx context.Context)

func (*Task) OnFinished

func (t *Task) OnFinished(g func())

func (*Task) Result

func (t *Task) Result() interface{}

func (*Task) Run

func (t *Task) Run() error

func (*Task) WaitFinish

func (t *Task) WaitFinish()

func (*Task) WaitFinishWithContext

func (t *Task) WaitFinishWithContext(ctx context.Context) bool

type TaskId

type TaskId struct {
	TxnId uint64
	Key   string
}

func NewTaskId

func NewTaskId(txnId uint64, key string) TaskId

func (TaskId) Hash

func (id TaskId) Hash() uint64

func (TaskId) String

func (id TaskId) String() string

Jump to

Keyboard shortcuts

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