internal

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const UIDPrefix = "#UID-"

UIDPrefix is the prefix to use for unique identifiers.

Variables

View Source
var Marshalers = map[string]has.Marshaler{}

Marshalers is a map of registered .wrj marshalers keyed by uppercased field names.

View Source
var NextUID <-chan string

NextUID returns a unique identifier. To keep the identifier compact it is a uint that is encoded in base 36 using the digits 0-9 and letters A-Z. This will result in an identifier in the range 0 to 3W5E11264SG0G prefixed with UIDPrefix. Examples for a unique identifier are #UID-0 & #UID-3W5E11264SG0G.

Functions

func AddMarshaler

func AddMarshaler(marshaler has.Marshaler, attr ...string)

AddMarshaler registers the passed Marshaler as handling marshaling for a named field in a .wrj file. The passed Marshaler can be a typed nil pointer such as (*Name)(nil).

Types

type BRL

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

BRL or 'Big Room Lock' is responsible for all of the 'in game' locking. Named in tribute to the Linux kernel 'big kernel lock' that is no more. In Linux the BKL stopped concurrency in kernel space. In WolfMUD the BRL stops concurrency within a 'location'. Unlike the BKL the BRL is not a recursive lock. If you need to change what you are locking, release all the locks held and reacquire them. Otherwise subtle and not so subtle BadThings™ are bound to happen.

Each BRL has a unique lock ID associated with it so that locks can be obtained and released in a consistent order. This is the classic resource hierarchy solution proposed by Dijkstra to the dining philosophers problem to avoid deadlocks and livelocks:

https://en.wikipedia.org/wiki/Dining_philosophers_problem

A BRL also fulfils the sync.Locker interface.

TODO: Add more details on the BRL, lockID and implications of room level locking.

func NewBRL

func NewBRL() BRL

NewBRL returns an initialised BRL with a unique lock ID.

func (BRL) Lock

func (brl BRL) Lock()

Lock locks the specified BRL and implements Lock for a sync.Locker

func (BRL) LockID

func (brl BRL) LockID() (id uint64)

LockID returns the unique lock ID associated with a specific BRL.

func (BRL) Unlock

func (brl BRL) Unlock()

Unlock unlocks the specified BRL and implements Unlock for a sync.Locker

Jump to

Keyboard shortcuts

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