coroutine

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context added in v1.11.5

func Context() context.Context

Context 获取全局顶层context

func GetContextWithCancel added in v1.11.5

func GetContextWithCancel() (context.Context, context.CancelFunc)

func Shutdown added in v1.11.5

func Shutdown()

Shutdown 关闭应用程序, 通知所有协程退出

func WaitForShutdown added in v1.13.1

func WaitForShutdown()

WaitForShutdown 阻塞等待关闭信号

Types

type Channel added in v1.19.3

type Channel[E any] struct {
	// contains filtered or unexported fields
}

Channel 多协程安全的channel

func (*Channel[E]) Close added in v1.19.3

func (c *Channel[E]) Close()

func (*Channel[E]) Pop added in v1.19.3

func (c *Channel[E]) Pop() E

func (*Channel[E]) Push added in v1.19.3

func (c *Channel[E]) Push(v E)

type PeriodicOnce deprecated added in v1.12.3

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

PeriodicOnce 周期性懒加载机制

Deprecated: 推荐 RollingOnce [wangfeng on 2024/1/22 10:33]

func (*PeriodicOnce) Do added in v1.12.3

func (o *PeriodicOnce) Do(f func())

func (*PeriodicOnce) Reset added in v1.12.3

func (o *PeriodicOnce) Reset()

Reset 被动的方式重置初始化done标志

type RollingMutex deprecated

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

RollingMutex 按指定rolling策略加锁, 指定周期内只加载一次

滑动窗口锁, 窗口期内只初始化一次, 目前只支持1天切换

Deprecated: 不推荐, 建议使用 RollingOnce

func (*RollingMutex) Date

func (o *RollingMutex) Date() string

func (*RollingMutex) Do

func (o *RollingMutex) Do(f func(), today ...func() (newDate string))

func (*RollingMutex) Reset

func (o *RollingMutex) Reset()

type RollingOnce added in v1.16.8

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

RollingOnce 周期性懒加载机制

func (*RollingOnce) Close added in v1.18.1

func (o *RollingOnce) Close()

Close 资源关闭方法

func (*RollingOnce) Do added in v1.16.8

func (o *RollingOnce) Do(f func())

func (*RollingOnce) GetCurrentAnchorPoint added in v1.19.1

func (o *RollingOnce) GetCurrentAnchorPoint() int64

GetCurrentAnchorPoint 获取当前时间窗口期的锚点

func (*RollingOnce) Reset added in v1.16.8

func (o *RollingOnce) Reset()

Reset 被动的方式重置初始化done标志

func (*RollingOnce) SetOffsetForZero added in v1.18.1

func (o *RollingOnce) SetOffsetForZero(offsetMilliSeconds int64)

SetOffsetForZero 设置时间窗口变化的偏移量

为非默认9点整重置done预留的功能性方法

func (*RollingOnce) SetOffsetTime added in v1.18.2

func (o *RollingOnce) SetOffsetTime(hour, minute int)

SetOffsetTime 用小时数,分钟数设置滑动窗口的偏移量

func (*RollingOnce) WindowIsExpired added in v1.19.2

func (o *RollingOnce) WindowIsExpired() bool

WindowIsExpired 检查当前窗口期的是否过期

type RollingWaitGroup added in v1.14.2

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

RollingWaitGroup 滑动窗口n的WaitGroup

func NewRollingWaitGroup added in v1.14.2

func NewRollingWaitGroup(n int) *RollingWaitGroup

NewRollingWaitGroup initialization RollingWaitGroup struct

func (*RollingWaitGroup) Add added in v1.14.2

func (g *RollingWaitGroup) Add(delta int)

func (*RollingWaitGroup) Done added in v1.14.2

func (g *RollingWaitGroup) Done()

func (*RollingWaitGroup) Wait added in v1.14.2

func (g *RollingWaitGroup) Wait()

type SpinLock added in v1.14.3

type SpinLock uint32

SpinLock 自旋锁对象定义

func (*SpinLock) Lock added in v1.14.3

func (sl *SpinLock) Lock()

Lock 加锁

todo: 未加验证

func (*SpinLock) UnLock added in v1.14.3

func (sl *SpinLock) UnLock()

UnLock 解锁

Jump to

Keyboard shortcuts

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