sync2

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2015 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const APPEND = "01235"

Variables

This section is empty.

Functions

This section is empty.

Types

type LockCond added in v0.2.2

type LockCond sync.Cond

LockCond is a wrapper of sync.Cond, each method will be called with lock

func NewLockCond added in v0.2.2

func NewLockCond(l sync.Locker) *LockCond

func WrapCond added in v0.2.2

func WrapCond(cond *sync.Cond) *LockCond

func (*LockCond) Broadcast added in v0.2.2

func (c *LockCond) Broadcast()

func (*LockCond) Cond added in v0.2.2

func (c *LockCond) Cond() *sync.Cond

func (*LockCond) Signal added in v0.2.2

func (c *LockCond) Signal()

func (*LockCond) Wait added in v0.2.2

func (c *LockCond) Wait()

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 uint32

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

func (*Once) Do

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

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

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