MCPcopy Create free account
hub / github.com/Monibuca/engine / TryRead

Method TryRead

track/reader-data.go:25–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25func (r *RingReader[T, F]) TryRead() (f F, err error) {
26 if r.Count > 0 {
27 preValue := r.Value
28 if preValue.IsDiscarded() {
29 preValue.ReaderLeave()
30 err = ErrDiscard
31 return
32 }
33 if !r.Next().Value.ReaderTryEnter() {
34 return
35 }
36 r.Ring = r.Next()
37 } else {
38 if !r.Value.ReaderTryEnter() {
39 return
40 }
41 }
42 if r.Value.IsDiscarded() {
43 err = ErrDiscard
44 return
45 }
46 r.Count++
47 f = r.Value
48 return
49}
50
51func (r *RingReader[T, F]) StopRead() {
52 if r.locked {

Callers

nothing calls this directly

Calls 4

IsDiscardedMethod · 0.65
ReaderLeaveMethod · 0.65
ReaderTryEnterMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected