Documentation ¶
Index ¶
- type Config
- type Environment
- func (env *Environment) GetLgoreState(lgoreId int) (LgoreState, error)
- func (env *Environment) Init(conf Config) error
- func (env *Environment) InitDefault() error
- func (env *Environment) LgoreCount() int
- func (env *Environment) Occupy(lgoreId int) error
- func (env *Environment) Release(lgoreId int) error
- type LgoreState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Specifies if we should pre-occupy all available cores // // TODO ignored for now OccupyAll bool // Specifies which cores should not be used as lgores // // There should be at least one core present in this slice. // Each value should be an index in range [0, NumCPUs), // where NumCPUs can be found from runtime.NumCPU(). ReserveCores []int }
Config environment config
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment manages all the lgores
func (*Environment) GetLgoreState ¶
func (env *Environment) GetLgoreState(lgoreId int) (LgoreState, error)
GetLgoreState returns `LgoreState` of a lgore
func (*Environment) Init ¶
func (env *Environment) Init(conf Config) error
Init initializes environment and lgores
func (*Environment) InitDefault ¶
func (env *Environment) InitDefault() error
InitDefault initializes `env` with default configuration
Default config sets `OccupyAll` to `false` and adds core 0 for reserve
func (*Environment) LgoreCount ¶
func (env *Environment) LgoreCount() int
LgoreCount returns number of available lgores
func (*Environment) Occupy ¶
func (env *Environment) Occupy(lgoreId int) error
Occupy locks calling goroutine to an lgore
Goroutine is locked to OS thread, and OS thread is locked to lgore's core.
func (*Environment) Release ¶
func (env *Environment) Release(lgoreId int) error
Release releases the lgore
This function should be called from the same goroutine that called `Occupy`. Lgore becomes available, and the locked OS thread allowed to run on any core again.
type LgoreState ¶
type LgoreState uint8
LgoreState represents lgore's current state
const ( // Invalid state for non-existing lgores Invalid LgoreState = iota // Available represents an lgore which can be occupied Available // Busy represents an lgore which is occupied Busy )