util

package
v0.0.0-...-1c597ed Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRC32

func CRC32(str string) uint32

func IsHaveInvalidPwdChar

func IsHaveInvalidPwdChar(strChar string) bool

是否为密码规定字符

func MD5

func MD5(data string) string

*

  • 对字符串进行MD5哈希
  • @param data string 要加密的字符串

Types

type BasePool

type BasePool interface {
	Run(i interface{})
	Shutdown()
}

type SyncMap

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

func NewSyncMap

func NewSyncMap() *SyncMap

func (*SyncMap) Check

func (m *SyncMap) Check(k interface{}) bool

Returns true if k is exist in the map.

func (*SyncMap) Clean

func (m *SyncMap) Clean()

func (*SyncMap) Delete

func (m *SyncMap) Delete(k interface{})

func (*SyncMap) Get

func (m *SyncMap) Get(k interface{}) interface{}

Get from maps return the k's value

func (*SyncMap) GetMap

func (m *SyncMap) GetMap() map[interface{}]interface{}

func (*SyncMap) Lock

func (m *SyncMap) Lock()

func (*SyncMap) Set

func (m *SyncMap) Set(k interface{}, v interface{}) bool

Maps the given key and value. Returns false if the key is already in the map and changes nothing.

func (*SyncMap) Unlock

func (m *SyncMap) Unlock()

type SyncQueue

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

Synchronous FIFO queue

func NewSyncQueue

func NewSyncQueue() *SyncQueue

Create a new SyncQueue

func (*SyncQueue) Close

func (q *SyncQueue) Close()

Close SyncQueue

After close, Pop will return nil without block, and TryPop will return v=nil, ok=True

func (*SyncQueue) Len

func (q *SyncQueue) Len() (l int)

Get the length of SyncQueue

func (*SyncQueue) Pop

func (q *SyncQueue) Pop() (v interface{})

Pop an item from SyncQueue, will block if SyncQueue is empty

func (*SyncQueue) PopAll

func (q *SyncQueue) PopAll() (v []interface{})

PopAll all items from SyncQueue, will block if SyncQueue is empty

func (*SyncQueue) Push

func (q *SyncQueue) Push(v interface{})

Push an item to SyncQueue. Always returns immediately without blocking

func (*SyncQueue) TryPop

func (q *SyncQueue) TryPop() (v interface{}, ok bool)

Try to pop an item from SyncQueue, will return immediately with bool=false if SyncQueue is empty

func (*SyncQueue) TryPopAll

func (q *SyncQueue) TryPopAll() (v []interface{}, ok bool)

Try to pop all items from SyncQueue, will return immediately with bool=false if SyncQueue is empty

type Work

type Work func(c interface{})

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(maxGoroutines int, c interface{}) *WorkerPool

func (*WorkerPool) Run

func (p *WorkerPool) Run(w Work)

func (*WorkerPool) Shutdown

func (p *WorkerPool) Shutdown()

Jump to

Keyboard shortcuts

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