giocache

package module
v0.0.0-...-291821f Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 3 Imported by: 0

README

giocache Go Reference

Package giocache provides an experimental layout cache implementation for Gio.

The implementation is rudimentary and probably not suitable for production use.

Documentation

Overview

Package giocache provides an experimental layout cache implementation for Gio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache holds cached rendering operations for gio.

func New

func New() *Cache

New prepares a new operation cache.

func (*Cache) Add

func (c *Cache) Add(cb func(op.MacroOp)) (op.CallOp, ID)

Add adds the given call to the cache and returns an ID for future use.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all entries from the cache.

func (*Cache) Context

func (c *Cache) Context(constraints layout.Constraints, metric unit.Metric) layout.Context

Context returns a graphical context for the cache with the given constraints and metric.

TODO: Consider making constraints cache-wide, provide an update function, and invalidate the cache when the constraints (and/or metric?) change.

func (*Cache) Delete

func (c *Cache) Delete(id ID)

Delete marks the call in the cache with the given ID as dead.

func (*Cache) Get

func (c *Cache) Get(id ID) (call op.CallOp, ok bool)

Get retrieves a call from the cache for id. The call is only valid until the cache is cleared or purged. It returns false if the id is no longer valid.

func (*Cache) Purge

func (c *Cache) Purge(threshold int) bool

Purge clears the cache if the number of dead items exceed threshold. It returns true if the cache was cleared.

type ID

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

ID identifies an operation within the cache.

func (ID) OK

func (id ID) OK() bool

OK returns true if the ID is valid.

Jump to

Keyboard shortcuts

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