system: update doc commands and remove mutex
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Successful in 2m59s
Test / Hpkg (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 4m28s
Test / Hakurei (race detector) (push) Successful in 5m4s
Test / Flake checks (push) Successful in 1m21s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Successful in 2m59s
Test / Hpkg (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 4m28s
Test / Hakurei (race detector) (push) Successful in 5m4s
Test / Flake checks (push) Successful in 1m21s
The mutex is not really doing anything, none of these methods make sense when called concurrently anyway. The copylocks analysis is still satisfied by the noCopy struct. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -9,20 +9,16 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// CopyFile registers an Op that copies from src.
|
||||
// A buffer is initialised with size cap and the Op faults if bytes read exceed n.
|
||||
// CopyFile appends [TmpfileOp] to [I].
|
||||
func (sys *I) CopyFile(payload *[]byte, src string, cap int, n int64) *I {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.Grow(cap)
|
||||
|
||||
sys.lock.Lock()
|
||||
sys.ops = append(sys.ops, &Tmpfile{payload, src, n, buf})
|
||||
sys.lock.Unlock()
|
||||
|
||||
sys.ops = append(sys.ops, &TmpfileOp{payload, src, n, buf})
|
||||
return sys
|
||||
}
|
||||
|
||||
type Tmpfile struct {
|
||||
// TmpfileOp reads up to n bytes from src and writes the resulting byte slice to payload.
|
||||
type TmpfileOp struct {
|
||||
payload *[]byte
|
||||
src string
|
||||
|
||||
@@ -30,8 +26,8 @@ type Tmpfile struct {
|
||||
buf *bytes.Buffer
|
||||
}
|
||||
|
||||
func (t *Tmpfile) Type() Enablement { return Process }
|
||||
func (t *Tmpfile) apply(*I) error {
|
||||
func (t *TmpfileOp) Type() Enablement { return Process }
|
||||
func (t *TmpfileOp) apply(*I) error {
|
||||
msg.Verbose("copying", t)
|
||||
|
||||
if t.payload == nil {
|
||||
@@ -59,12 +55,12 @@ func (t *Tmpfile) apply(*I) error {
|
||||
*t.payload = t.buf.Bytes()
|
||||
return nil
|
||||
}
|
||||
func (t *Tmpfile) revert(*I, *Criteria) error { t.buf.Reset(); return nil }
|
||||
func (t *TmpfileOp) revert(*I, *Criteria) error { t.buf.Reset(); return nil }
|
||||
|
||||
func (t *Tmpfile) Is(o Op) bool {
|
||||
t0, ok := o.(*Tmpfile)
|
||||
return ok && t0 != nil &&
|
||||
t.src == t0.src && t.n == t0.n
|
||||
func (t *TmpfileOp) Is(o Op) bool {
|
||||
target, ok := o.(*TmpfileOp)
|
||||
return ok && t != nil && target != nil &&
|
||||
t.src == target.src && t.n == target.n
|
||||
}
|
||||
func (t *Tmpfile) Path() string { return t.src }
|
||||
func (t *Tmpfile) String() string { return fmt.Sprintf("up to %d bytes from %q", t.n, t.src) }
|
||||
func (t *TmpfileOp) Path() string { return t.src }
|
||||
func (t *TmpfileOp) String() string { return fmt.Sprintf("up to %d bytes from %q", t.n, t.src) }
|
||||
|
||||
Reference in New Issue
Block a user