internal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: BSD-3-Clause, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fan

type Fan[T any] struct {
	// contains filtered or unexported fields
}

Fan is a fan-out channel.

func (*Fan[T]) Add

func (f *Fan[T]) Add() chan T

Add adds a listener to the fan-out channel.

func (*Fan[T]) Close

func (f *Fan[T]) Close()

Close removes a listener from the fan-out channel.

func (*Fan[T]) Send

func (f *Fan[T]) Send(v T)

Send sends a value to all listeners.

type Handle

type Handle uintptr

func NewHandle

func NewHandle(v any) Handle

NewHandle returns a handle for a given value.

func (Handle) Delete

func (h Handle) Delete()

Delete invalidates a handle.

func (Handle) IsValid

func (h Handle) IsValid() bool

IsValid returns true if the handle is valid.

func (Handle) Value

func (h Handle) Value() any

Value returns the associated Go value for a valid handle.

The method panics if the handle is invalid.

type Scheduler

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

Scheduler is a runs a set of functions in the given an single runner function.

That is useful for running a set of functions in a single goroutine, linked to the main loop.

func NewScheduler

func NewScheduler(runner func(f func())) (s *Scheduler)

NewScheduler creates a new Scheduler.

func (*Scheduler) MustRun

func (s *Scheduler) MustRun(f func())

MustRun runs a function in the scheduler, that is guaranteed to run and duplication may happen if misused.

func (*Scheduler) Run

func (s *Scheduler) Run(method int, f func())

Run runs a function in the scheduler, however it only allow one function per method.

That will replace the old declared function if the method is already in use.

func (*Scheduler) SetRunner

func (s *Scheduler) SetRunner(r func(f func()))

SetRunner sets the runner function.

Jump to

Keyboard shortcuts

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