~/bend-docscommunity

src/host/fdcache.bend checks

raw source on the hub · import 0xf5a4b65b629b862013786b5337fcbdbf/src/host/fdcache.bend as Fdcache

1 import
import Base

Types

type Slot source · line 12 · raw

Data

type Cache source · line 15 · raw

Data

type Found source · line 19 · raw

Data

A lookup: the descriptor (Fdc.none on a miss) and the cache after it.

type Freed source · line 23 · raw

Data

A put or a flush: the descriptors to close and the cache after it.

Definitions

def Fdc.size source · line 26 · raw

Nat

def Fdc.none source · line 29 · raw

U32

def Fdc.empty.go source · line 32 · raw

@n:Nat -> List<&2, Slot>

def Fdc.empty source · line 39 · raw

Cache

def Fdc.is source · line 42 · raw

@+s:Slot -> @+share:U32 -> @+rel:String -> @+wr:Bool -> Bool

def Fdc.touch source · line 47 · raw

@+s:Slot -> @+now:U32 -> Slot

def Fdc.find.go source · line 54 · raw

@slots:List<&2, Slot> -> @+share:U32 -> @+rel:String -> @+wr:Bool -> @+now:U32 -> List<&2, Slot>

The slot that matches, marked used at now, and its descriptor; the first match wins (there is at most one).

def Fdc.fd_of source · line 63 · raw

@slots:List<&2, Slot> -> @+share:U32 -> @+rel:String -> @+wr:Bool -> U32

def Fdc.find source · line 74 · raw

@+c:Cache -> @+share:U32 -> @+rel:String -> @+wr:Bool -> Found

A lookup (hvf_fdc_find): a hit marks its slot used now (the tick moves on); a miss changes nothing.

def Fdc.least source · line 83 · raw

@slots:List<&2, Slot> -> @+m:U32 -> U32

The least used mark over the slots (an empty slot's is 0).

def Fdc.keep source · line 92 · raw

@+s:Slot -> @+d:Freed -> Freed

def Fdc.flush.add source · line 99 · raw

@mine:Bool -> @+fd:U32 -> @+s:Slot -> @+d:Freed -> Freed

def Fdc.replace source · line 106 · raw

@slots:List<&2, Slot> -> @+m:U32 -> @+new:Slot -> Freed

The first slot marked m takes the new file; the descriptor it held, if it was in use, is closed.

def Fdc.with_tick source · line 117 · raw

@+t:U32 -> @+d:Freed -> Freed

def Fdc.put source · line 125 · raw

@+c:Cache -> @+share:U32 -> @+rel:String -> @+wr:Bool -> @+fd:U32 -> Freed

A new open file (hvf_fdc_put, after a miss).

def Fdc.flush.go source · line 132 · raw

@slots:List<&2, Slot> -> @+share:U32 -> Freed

A share's slots emptied (hvf_fdc_flush): each one in use closes.

def Fdc.flush source · line 142 · raw

@+c:Cache -> @+share:U32 -> Freed

def Fdc.count source · line 148 · raw

@slots:List<&2, Slot> -> U32

How many slots are in use.

def Fdc.slots source · line 157 · raw

@+c:Cache -> List<&2, Slot>

def Fdc.done_cache source · line 162 · raw

@+d:Freed -> Cache

def Fdc.done_closed source · line 167 · raw

@+d:Freed -> List<&2, U32>

def Fdc.look_fd source · line 172 · raw

@+l:Found -> U32

def Fdc.look_cache source · line 177 · raw

@+l:Found -> Cache

def Fdc.invalidates source · line 188 · raw

@+op:U32 -> Bool

The host operations that can change what a path names, so the share's open files are dropped first (hvf_fs_run's op numbers: 4 create, 5 mkdir, 6 remove, 7 rename, 10 symlink).

def Fdc.victim.go source · line 194 · raw

@ws:List<&2, U32> -> @+i:U32 -> @+best:U32 -> @+bhi:U32 -> @+blo:U32 -> U32

The slot a newly opened file takes, from each slot's last use as the host reports it ([hi, lo] per slot; 0 is an empty slot): the least recently used, the first such (as Fdc.replace).

def Fdc.victim source · line 206 · raw

@+ws:List<&2, U32> -> U32