maxidmmap

package
v0.0.0-...-ab92e14 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package maxidmmap provides a type for working with atomically unique prompting-related IDs, backed by a memory mapped file.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMaxIDMmapClosed = fmt.Errorf("cannot compute next ID on max ID mmap which has already been closed")
)

Functions

This section is empty.

Types

type MaxIDMmap

type MaxIDMmap []byte

MaxIDMmap is a wrapper for ID tracked backed by a mmap'ed file.

func OpenMaxIDMmap

func OpenMaxIDMmap(maxIDFilepath string) (MaxIDMmap, error)

OpenMaxIDMmap opens and mmaps the given maxIDFilepath, returning the corresponding MaxIDMmap.

If the maxIDFilepath does not exist, or if the file is malformed, it is reset to an 8-byte file with a max ID of 0. If the file cannot be created, opened, or mmaped, returns an error and a nil MaxIDMmap.

func (*MaxIDMmap) Close

func (mim *MaxIDMmap) Close() error

Close unmaps the underlying byte slice corresponding to the receiving max ID mmap, if it has not already been unmapped.

The caller must ensure that any relevant lock is held.

func (*MaxIDMmap) IsClosed

func (mim *MaxIDMmap) IsClosed() bool

IsClosed returns whether the receiving max ID mmap has been unmapped and closed, which is indicated by the underlying byte slice being nil.

The caller must ensure that any relevant lock is held.

func (MaxIDMmap) NextID

func (mim MaxIDMmap) NextID() (prompting.IDType, error)

NextID increments the monotonic max ID integer and returns the corresponding ID.

The caller must ensure that any relevant lock is held.

Jump to

Keyboard shortcuts

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