Index | Files

package gc

import ""

Package gc defines a generic garbage collector.


Package Files


type Collector Uses

type Collector struct {
    // World specifies a World that should be stopped before a
    // collection and started again after.
    World World

    Marker         Marker
    Roots          Enumerator
    Sweeper        Enumerator
    ItemEnumerator ItemEnumerator
    Deleter        Deleter

A Collector performs a garbage collection.

func (*Collector) Collect Uses

func (c *Collector) Collect(ctx context.Context) (err error)

Collect performs a garbage collection.

type Deleter Uses

type Deleter interface {
    // Delete deletes an item that was deemed unreachable via
    // the garbage collector.
    // It must be safe for calls from concurrent goroutines.
    Delete(Item) error

type Enumerator Uses

type Enumerator interface {
    // Enumerate enumerates items (which items depends on usage)
    // and sends them to the provided channel. Regardless of return
    // value, the channel should be closed.
    // If the provided context is closed, Enumerate should return
    // with an error (typically context.Canceled)
    Enumerate(context.Context, chan<- Item) error

Enumerator enumerates items.

type Item Uses

type Item interface{}

Item is something that exists that may or may not survive a GC collection.

type ItemEnumerator Uses

type ItemEnumerator interface {
    // EnumerateItme is like Enuerator's Enumerate, but specific
    // to the provided item.
    EnumerateItem(context.Context, Item, chan<- Item) error

ItemEnumerator enumerates all the edges out from an item.

type Marker Uses

type Marker interface {
    // Mark marks that an item should exist.
    // It must be safe for calls from concurrent goroutines.
    Mark(Item) error

    // IsMarked returns whether the item is marked.
    // It must be safe for calls from concurrent goroutines.
    IsMarked(Item) (bool, error)

type World Uses

type World interface {
    Stop() error
    Start() error

World defines the thing that should be stopped before GC and started after.

Package gc imports 4 packages (graph). Updated 2019-06-30. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).