File: entryhandle.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 872 kB
  • sloc: makefile: 4
file content (40 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package conntrack

import (
	"sync"
	"time"
)

type EntryHandle struct {
	reason   string
	e        Entry
	priority priority
	i        *Instance
	expires  time.Time
	created  time.Time
	wake     sync.Mutex
}

func (eh *EntryHandle) Done() {
	expvars.Add("entry handles done", 1)
	timeout := eh.timeout()
	eh.expires = time.Now().Add(timeout)
	if timeout <= 0 {
		eh.remove()
	} else {
		time.AfterFunc(eh.timeout(), eh.remove)
	}
}

func (eh *EntryHandle) Forget() {
	expvars.Add("entry handles forgotten", 1)
	eh.remove()
}

func (eh *EntryHandle) remove() {
	eh.i.remove(eh)
}

func (eh *EntryHandle) timeout() time.Duration {
	return eh.i.Timeout(eh.e)
}