goroutine

package
v0.0.0-...-8093761 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPanicHandler

func DefaultPanicHandler(panicErr interface{})

DefaultPanicHandler 기본 패닉 핸들러 함수

Parameters:

  • panicErr: 패닉 에러

Types

type GoroutineManager

type GoroutineManager struct {
	PanicHandler PanicHandleFunc
	// contains filtered or unexported fields
}

GoroutineManager 전체 고루틴 관리 정보 구조체

func NewGoroutineManager

func NewGoroutineManager() *GoroutineManager

NewGoroutineManager 고루틴 관리 구조체 생성

Returns:

  • *GoroutineManager

func (*GoroutineManager) AddTask

func (gm *GoroutineManager) AddTask(name string, task func(ctx context.Context))

AddTask 고루틴을 작업에 등록

Parameters:

  • name: 작업명 (key)
  • task: function (value)

func (*GoroutineManager) RemoveTask

func (gm *GoroutineManager) RemoveTask(name string, timeout time.Duration) error

RemoveTask 고루틴 종료 및 작업 제거

Parameters:

  • name: 작업명
  • timeout: WaitGroup 타임아웃

Returns:

  • error: 성공(nil), 타임아웃 발생(error)

func (*GoroutineManager) Start

func (gm *GoroutineManager) Start(name string) error

Start 작업에 등록된 개별 고루틴 가동

Parameters:

  • name: 작업명

Returns:

  • error: 성공(nil), 실패(error)

func (*GoroutineManager) StartAll

func (gm *GoroutineManager) StartAll()

StartAll 작업에 등록된 모든 고루틴 가동

func (*GoroutineManager) Stop

func (gm *GoroutineManager) Stop(name string, timeout time.Duration) error

Stop 작업에 등록된 개별 고루틴 가동 정지

Parameters:

  • name: 작업명
  • timeout: WaitGroup 타임아웃

Returns:

  • error: 성공(nil), 타임아웃 발생(error)

func (*GoroutineManager) StopAll

func (gm *GoroutineManager) StopAll(timeout time.Duration) error

StopAll 작업에 등록된 모든 고루틴 가동 정지

Parameters:

  • timeout: WaitGroup 타임아웃

Returns:

  • error: 성공(nil), 타임아웃 발생(error)

type PanicHandleFunc

type PanicHandleFunc func(interface{})

PanicHandleFunc 패닉 핸들러 함수 타입 정의

type WaitError

type WaitError int
const (
	WaitSuccess WaitError = iota
	WaitTimeout
	WaitInvalidParam
)

func WaitCancelWithTimeout

func WaitCancelWithTimeout(ctx context.Context, timeout time.Duration) WaitError

WaitCancelWithTimeout 컨텍스트 종료 타임아웃 대기

Parameters:

  • ctx: context
  • timeout: 타임아웃

Returns:

  • WaitError: 종료 신호 수신(WaitSuccess), 타임아웃 발생(WaitTimeout)

func WaitGroupWithTimeout

func WaitGroupWithTimeout(wg *sync.WaitGroup, timeout time.Duration) WaitError

WaitGroupWithTimeout 고루틴 종료 타임아웃 대기

Parameters:

  • wg: WaitGroup
  • timeout: 타임아웃

Returns:

  • WaitError: 고루틴 정상 종료(WaitSuccess), 실패(WaitError)

Jump to

Keyboard shortcuts

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