Documentation
¶
Overview ¶
Package idtable gives things small ids, which the C engine passes back to the host on every callback, and finds a thing by its id with two atomic reads and no lock: callbacks of VMs on many goroutines do not wait for each other, and do not write to memory they share.
Index ¶
Constants ¶
const Max = chunks * chunkSize
Max is one more than the largest id a Table hands out.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
A Table holds things by id. The zero Table is empty and ready to use. Add and Remove take a lock, Get takes none. A table hands out its own ids by Add and Remove, or holds things under the ids of another table by Put and Delete, never both.
func (*Table[T]) Add ¶
Add gives x an id: never 0, and not the id of another thing in the table. An id that Remove took back is handed out again.