sync2

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const APPEND = "01235"

Variables

This section is empty.

Functions

func LockDo

func LockDo(lock sync.Locker, fn func())

LockDo do function in lock

Types

type MRWMutex

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

func NewMRWMutex

func NewMRWMutex() *MRWMutex

func (*MRWMutex) Lock

func (m *MRWMutex) Lock(lockId string)

func (*MRWMutex) NewId

func (m *MRWMutex) NewId(id string) string

func (*MRWMutex) RLock

func (m *MRWMutex) RLock(lockId string)

func (*MRWMutex) RLocker

func (m *MRWMutex) RLocker(lockId string) sync.Locker

func (*MRWMutex) RUnlock

func (m *MRWMutex) RUnlock(lockId string)

func (*MRWMutex) Unlock

func (m *MRWMutex) Unlock(lockId string)

type Once

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

Once is an object that will perform exactly one action unless call Undo.

func (*Once) Do

func (o *Once) Do(f func())

Do will do f only once no matter it's successful or not if f is blocked, Do will also be

func (*Once) ErrorDo

func (o *Once) ErrorDo(f func() error) error

ErrorDo will do f only once when function call is successful, if function return error, Once will be failed

func (*Once) Undo

func (o *Once) Undo()

Undo restore Once's state to initial, then you can call Do or ErrorDo again

type Queue

type Queue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Queue) Dequeue

func (q *Queue) Dequeue() Task

func (*Queue) Enqueue

func (q *Queue) Enqueue(t Task) bool

type Scheduler

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

func New

func New() *Scheduler

func (*Scheduler) AddQueue

func (s *Scheduler) AddQueue(id uint32, capacity int)

func (*Scheduler) AddTask

func (s *Scheduler) AddTask(id uint32, t Task) (success bool)

func (*Scheduler) GetTask

func (s *Scheduler) GetTask() Task

func (*Scheduler) Run

func (s *Scheduler) Run()

type Signal

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

func NewSignal

func NewSignal() *Signal

func (*Signal) Notify

func (s *Signal) Notify()

func (*Signal) Wait

func (s *Signal) Wait()

type Spinlock

type Spinlock int32

Spinlock should not be used on single cpu(core) machines. if one goroute take out the lock, the programm will be died if another goroutine try to take out the lock again

func (*Spinlock) Lock

func (s *Spinlock) Lock()

func (*Spinlock) Unlock

func (s *Spinlock) Unlock()

type Task

type Task interface {
	Execute()
}

Task Schedule By scale, each user has his scale

type TaskFunc

type TaskFunc func()

func (TaskFunc) Execute

func (f TaskFunc) Execute()

Jump to

Keyboard shortcuts

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