gofine

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: MIT Imports: 4 Imported by: 0

README

LGORE

CPU Affinity for Go goroutines (Unix systems only)

Warnings

Use at your own risk

Usage

TODO

Why

TODO

Documentation

Index

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
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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