task

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Futex added in v0.35.0

type Futex struct {
	Uint32
	// contains filtered or unexported fields
}

A futex is a way for userspace to wait with the pointer as the key, and for another thread to wake one or all waiting threads keyed on the same pointer.

A futex does not change the underlying value, it only reads it before to prevent lost wake-ups.

func (*Futex) Wait added in v0.35.0

func (f *Futex) Wait(cmp uint32) (awoken bool)

Atomically check for cmp to still be equal to the futex value and if so, go to sleep. Return true if we were definitely awoken by a call to Wake or WakeAll, and false if we can't be sure of that.

func (*Futex) Wake added in v0.35.0

func (f *Futex) Wake()

Wake a single waiter.

func (*Futex) WakeAll added in v0.35.0

func (f *Futex) WakeAll()

Wake all waiters.

type PMutex added in v0.35.0

type PMutex struct {
}

PMutex is a real mutex on systems that can be either preemptive or threaded, and a dummy lock on other (purely cooperative) systems.

It is mainly useful for short operations that need a lock when threading may be involved, but which do not need a lock with a purely cooperative scheduler.

func (*PMutex) Lock added in v0.35.0

func (m *PMutex) Lock()

func (*PMutex) Unlock added in v0.35.0

func (m *PMutex) Unlock()

type Queue

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

Queue is a FIFO container of tasks. The zero value is an empty queue.

func (*Queue) Append

func (q *Queue) Append(other *Queue)

Append pops the contents of another queue and pushes them onto the end of this queue.

func (*Queue) Empty added in v0.14.0

func (q *Queue) Empty() bool

Empty checks if the queue is empty.

func (*Queue) Pop

func (q *Queue) Pop() *Task

Pop a task off of the queue.

func (*Queue) Push

func (q *Queue) Push(t *Task)

Push a task onto the queue.

type Stack

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

Stack is a LIFO container of tasks. The zero value is an empty stack. This is slightly cheaper than a queue, so it can be preferable when strict ordering is not necessary.

func (*Stack) Pop

func (s *Stack) Pop() *Task

Pop a task off of the stack.

func (*Stack) Push

func (s *Stack) Push(t *Task)

Push a task onto the stack.

func (*Stack) Queue

func (s *Stack) Queue() Queue

Queue moves the contents of the stack into a queue. Elements can be popped from the queue in the same order that they would be popped from the stack.

type Task

type Task struct {
	// Next is a field which can be used to make a linked list of tasks.
	Next *Task

	// Ptr is a field which can be used for storing a pointer.
	Ptr unsafe.Pointer

	// Data is a field which can be used for storing state information.
	Data uint64

	// DeferFrame stores a pointer to the (stack allocated) defer frame of the
	// goroutine that is used for the recover builtin.
	DeferFrame unsafe.Pointer
	// contains filtered or unexported fields
}

Task is a state of goroutine for scheduling purposes.

func (*Task) DataAtomicUint32 added in v0.35.0

func (t *Task) DataAtomicUint32() *Uint32

DataAtomicUint32 returns the Data field as an atomic-if-needed Uint32 value.

func (*Task) DataUint32 added in v0.35.0

func (t *Task) DataUint32() uint32

DataUint32 returns the Data field as a uint32. The value is only valid after setting it through SetDataUint32 or by storing to it using DataAtomicUint32.

func (*Task) SetDataUint32 added in v0.35.0

func (t *Task) SetDataUint32(val uint32)

SetDataUint32 updates the uint32 portion of the Data field (which could be the first 4 or last 4 bytes depending on the architecture endianness).

type Uint32 added in v0.35.0

type Uint32 = pseudoAtomic[uint32]

Uint32 is an atomic uint32 when multithreading is enabled, and a plain old uint32 otherwise.

type Uint64 added in v0.35.0

type Uint64 = pseudoAtomic[uint64]

Uint64 is an atomic uint64 when multithreading is enabled, and a plain old uint64 otherwise.

type Uintptr added in v0.35.0

type Uintptr = pseudoAtomic[uintptr]

Uintptr is an atomic uintptr when multithreading is enabled, and a plain old uintptr otherwise.

Jump to

Keyboard shortcuts

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