disk

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 3 Imported by: 15

Documentation

Index

Constants

View Source
const BlockSize uint64 = 4096

Variables

This section is empty.

Functions

func Barrier deprecated

func Barrier()

Barrier (see the Disk documentation)

Deprecated: use Get() and the Disk method

func Init

func Init(d Disk)

Init sets up the global disk

func Size deprecated

func Size() uint64

Size (see the Disk documentation)

Deprecated: use Get() and the Disk method

func Write deprecated

func Write(a uint64, v Block)

Write (see the Disk documentation)

Deprecated: use Get() and the Disk method

Types

type Block

type Block = []byte

Block is a 4096-byte buffer

func Read deprecated

func Read(a uint64) Block

Read (see the Disk documentation)

Deprecated: use Get() and the Disk method

type Disk

type Disk interface {
	// Read reads a disk block by address
	//
	// Expects a < Size().
	Read(a uint64) Block

	// ReadTo reads the disk block at a and stores the result in b
	//
	// Expects a < Size().
	ReadTo(a uint64, b Block)

	// Write updates a disk block by address
	//
	// Expects a < Size().
	Write(a uint64, v Block)

	// Size reports how big the disk is, in blocks
	Size() uint64

	// Barrier ensures data is persisted.
	//
	// When it returns, all outstanding writes are guaranteed to be durably on
	// disk
	Barrier()

	// Close releases any resources used by the disk and makes it unusable.
	Close()
}

Disk provides access to a logical block-based disk

func Get

func Get() Disk

Get returns the previously-initialized global disk

type FileDisk

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

func NewFileDisk

func NewFileDisk(path string, numBlocks uint64) (FileDisk, error)

func (FileDisk) Barrier

func (d FileDisk) Barrier()

func (FileDisk) Close

func (d FileDisk) Close()

func (FileDisk) Read

func (d FileDisk) Read(a uint64) Block

func (FileDisk) ReadTo

func (d FileDisk) ReadTo(a uint64, buf Block)

func (FileDisk) Size

func (d FileDisk) Size() uint64

func (FileDisk) Write

func (d FileDisk) Write(a uint64, v Block)

type MemDisk

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

func NewMemDisk

func NewMemDisk(numBlocks uint64) MemDisk

func (MemDisk) Barrier

func (d MemDisk) Barrier()

func (MemDisk) Close

func (d MemDisk) Close()

func (MemDisk) Read

func (d MemDisk) Read(a uint64) Block

func (MemDisk) ReadTo

func (d MemDisk) ReadTo(a uint64, buf Block)

func (MemDisk) Size

func (d MemDisk) Size() uint64

func (MemDisk) Write

func (d MemDisk) Write(a uint64, v Block)

Jump to

Keyboard shortcuts

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