Home Download Docs Code Community
import "perkeep/pkg/gc"
Overview
Index

Overview ▾

Package gc defines a generic garbage collector.

Index

type Collector
    func (c *Collector) Collect(ctx context.Context) (err error)
type Deleter
type Enumerator
type Item
type ItemEnumerator
type Marker
type World

Package files

gc.go

type Collector

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

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

Collect performs a garbage collection.

type Deleter

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

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

type Item interface{}

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

type ItemEnumerator

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

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

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

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

Website layout inspired by memcached.
Content by the authors.