goroutines

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 15 Imported by: 0

README

サンプルリスト

このディレクトリには以下のサンプルがあります。

file example name note
nonstop.go goroutines_nonstop ゴルーチンを待ち合わせ無しで走らせるサンプルです
withdonechannel.go goroutines_with_done_channel doneチャネルを用いて待ち合わせを行うサンプルです
withwaitgroup.go goroutines_with_waitgroup sync.WaitGroupを用いて待ち合わせを行うパターンです
withcontextcancel.go goroutines_with_context_cancel context.Contextを用いて待ち合わせを行うサンプルです
withcontexttimeout.go goroutines_with_context_timeout context.Contextを用いてタイムアウト付きで待ち合わせを行うサンプルです
withcontextdeadline.go goroutines_with_context_deadline context.Context::WithDeadline を使ったサンプルです
selectnilchan1.go goroutines_select_nil_chan_1 select ステートメントで nil チャネル を使って選択されるチャネルの有効・無効を切り替えるサンプルです (1)
selectnilchan2.go goroutines_select_nil_chan_2 select ステートメントで nil チャネル を使って選択されるチャネルの有効・無効を切り替えるサンプルです (2)
usingchansemaphore.go goroutines_using_chan_semaphore チャネルでセマフォの動作を行わせるサンプルです
usingmutex.go goroutines_using_mutex sync.Mutex を利用したサンプルです
workerpool.go goroutines_workerpool Worker Pool パターンのサンプルです
context_and_timeafterfunc.go goroutines_context_and_timeafterfunc ContextAndTimeAfterFunc は、Context と time.AfterFunc でキャンセルするサンプルです

Documentation

Overview

Package goroutines -- ゴルーチンについてのサンプルが配置されているパッケージです。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextAndTimeAfterFunc added in v0.5.0

func ContextAndTimeAfterFunc() error

ContextAndTimeAfterFunc は、Context と time.AfterFunc でキャンセルするサンプルです.

func NewRegister

func NewRegister() mapping.Register

NewRegister -- このパッケージ用のサンプルを登録する mapping.Register を生成します。

func NonStop

func NonStop() error

NonStop -- ゴルーチンを待ち合わせ無しで走らせるサンプルです.

投げっぱなしのゴルーチンを作る場合に使います。 通常待ち合わせ無しの非同期処理は行うべきではありません。

func SelectNilChan1

func SelectNilChan1() error

SelectNilChan1 -- select ステートメントで nil チャネル を使って選択されるチャネルの有効・無効を切り替えるサンプルです (1).

func SelectNilChan2

func SelectNilChan2() error

SelectNilChan2 -- select ステートメントで nil チャネル を使って選択されるチャネルの有効・無効を切り替えるサンプルです (2).

func SelectNilChan3 added in v0.4.2

func SelectNilChan3() error

SelectNilChan3 -- select ステートメントで nil チャネル を使って選択されるチャネルの有効・無効を切り替えるサンプルです (3).

シンプルな形のサンプル。

func UsingChanSemaphore

func UsingChanSemaphore() error

UsingChanSemaphore -- チャネルでセマフォの動作を行わせるサンプルです.

REFERENCES::

func UsingMutex

func UsingMutex() error

UsingMutex -- sync.Mutex を利用したサンプルです

func WithContextCancel

func WithContextCancel() error

WithContextCancel -- context.Contextを用いて待ち合わせを行うサンプルです.

func WithContextCancelCause added in v0.5.0

func WithContextCancelCause() error

WithContextCancelCause は、Go 1.20 で新規追加された context.WithCancelCause のサンプルです.

REFERENCES

func WithContextDeadline

func WithContextDeadline() error

WithContextDeadline -- context.WithDeadline を使ったサンプルです

func WithContextTimeout

func WithContextTimeout() error

WithContextTimeout -- context.Contextを用いてタイムアウト付きで待ち合わせを行うサンプルです

func WithDoneChannel

func WithDoneChannel() error

WithDoneChannel -- doneチャネルを用いて待ち合わせを行うサンプルです.

func WithWaitGroup

func WithWaitGroup() error

WithWaitGroup -- sync.WaitGroupを用いて待ち合わせを行うパターンです.

func WorkerPool added in v0.2.9

func WorkerPool() error

WorkerPool -- Worker Pool パターンのサンプルです.

REFENRECES

Types

This section is empty.

Directories

Path Synopsis
Package chansemaphore は、チャネルでセマフォの動作を実現するサンプルが配置されています
Package chansemaphore は、チャネルでセマフォの動作を実現するサンプルが配置されています
binarysemaphore
Package binarysemaphore は、チャネルでバイナリセマフォを表現しています.
Package binarysemaphore は、チャネルでバイナリセマフォを表現しています.
countingsemaphore
Package countingsemaphore は、チャネルで計数セマフォを表現しています.
Package countingsemaphore は、チャネルで計数セマフォを表現しています.
Package leak -- ゴルーチンリークについてのサンプルが配置されているパッケージです。
Package leak -- ゴルーチンリークについてのサンプルが配置されているパッケージです。

Jump to

Keyboard shortcuts

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