all repos

rss-tools @ master

get rss feed from sources that(i need and) dont provide one

rss-tools/vendor/go.etcd.io/bbolt/internal/freelist/freelist.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
we're vendoring now, 7 days ago
1
package freelist
2
3
import (
4
	"go.etcd.io/bbolt/internal/common"
5
)
6
7
type ReadWriter interface {
8
	// Read calls Init with the page ids stored in the given page.
9
	Read(page *common.Page)
10
11
	// Write writes the freelist into the given page.
12
	Write(page *common.Page)
13
14
	// EstimatedWritePageSize returns the size in bytes of the freelist after serialization in Write.
15
	// This should never underestimate the size.
16
	EstimatedWritePageSize() int
17
}
18
19
type Interface interface {
20
	ReadWriter
21
22
	// Init initializes this freelist with the given list of pages.
23
	Init(ids common.Pgids)
24
25
	// Allocate tries to allocate the given number of contiguous pages
26
	// from the free list pages. It returns the starting page ID if
27
	// available; otherwise, it returns 0.
28
	Allocate(txid common.Txid, numPages int) common.Pgid
29
30
	// Count returns the number of free and pending pages.
31
	Count() int
32
33
	// FreeCount returns the number of free pages.
34
	FreeCount() int
35
36
	// PendingCount returns the number of pending pages.
37
	PendingCount() int
38
39
	// AddReadonlyTXID adds a given read-only transaction id for pending page tracking.
40
	AddReadonlyTXID(txid common.Txid)
41
42
	// RemoveReadonlyTXID removes a given read-only transaction id for pending page tracking.
43
	RemoveReadonlyTXID(txid common.Txid)
44
45
	// ReleasePendingPages releases any pages associated with closed read-only transactions.
46
	ReleasePendingPages()
47
48
	// Free releases a page and its overflow for a given transaction id.
49
	// If the page is already free or is one of the meta pages, then a panic will occur.
50
	Free(txId common.Txid, p *common.Page)
51
52
	// Freed returns whether a given page is in the free list.
53
	Freed(pgId common.Pgid) bool
54
55
	// Rollback removes the pages from a given pending tx.
56
	Rollback(txId common.Txid)
57
58
	// Copyall copies a list of all free ids and all pending ids in one sorted list.
59
	// f.count returns the minimum length required for dst.
60
	Copyall(dst []common.Pgid)
61
62
	// Reload reads the freelist from a page and filters out pending items.
63
	Reload(p *common.Page)
64
65
	// NoSyncReload reads the freelist from Pgids and filters out pending items.
66
	NoSyncReload(pgIds common.Pgids)
67
68
	// freePageIds returns the IDs of all free pages. Returns an empty slice if no free pages are available.
69
	freePageIds() common.Pgids
70
71
	// pendingPageIds returns all pending pages by transaction id.
72
	pendingPageIds() map[common.Txid]*txPending
73
74
	// release moves all page ids for a transaction id (or older) to the freelist.
75
	release(txId common.Txid)
76
77
	// releaseRange moves pending pages allocated within an extent [begin,end] to the free list.
78
	releaseRange(begin, end common.Txid)
79
80
	// mergeSpans is merging the given pages into the freelist
81
	mergeSpans(ids common.Pgids)
82
}