Documentation
¶
Index ¶
Constants ¶
const ( // Initial state: the goroutine state is saved on the stack. RunStatePaused = iota // The goroutine is running right now. RunStateRunning // The goroutine is running, but already marked as "can resume". // The next call to Pause() won't actually pause the goroutine. RunStateResuming )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mutex ¶ added in v0.36.0
type Mutex struct {
// contains filtered or unexported fields
}
type PMutex ¶ added in v0.35.0
type PMutex = Mutex
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.
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 ¶
Append pops the contents of another queue and pushes them onto the end of this queue.
type Semaphore ¶ added in v0.38.0
type Semaphore struct {
// contains filtered or unexported fields
}
Barebones semaphore implementation. The main limitation is that if there are multiple waiters, a single Post() call won't do anything. Only when Post() has been called to awaken all waiters will the waiters proceed. This limitation is not a problem when there will only be a single waiter.
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.
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 // This is needed for some crypto packages. FipsIndicator uint8 // State of the goroutine: running, paused, or must-resume-next-pause. // This extra field doesn't increase memory usage on 32-bit CPUs and above, // since it falls into the padding of the FipsIndicator bit above. RunState uint8 // 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
DataAtomicUint32 returns the Data field as an atomic-if-needed Uint32 value.
func (*Task) DataUint32 ¶ added in v0.35.0
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
SetDataUint32 updates the uint32 portion of the Data field (which could be the first 4 or last 4 bytes depending on the architecture endianness).