gc

package
v0.0.0-...-c5af384 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gc defines a generic garbage collector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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.ErrCanceled)
	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.

Jump to

Keyboard shortcuts

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