zrcadlo
https://github.com/Hilbis/Hilbish
synchronizováno 2025-07-18 16:52:02 +00:00
perf: use struct{} for done channel in timer instead of bool
Tento commit je obsažen v:
rodič
8f6f27e647
revize
a4b358fd9c
4
timer.go
4
timer.go
@ -25,7 +25,7 @@ type timer struct{
|
|||||||
fun *rt.Closure
|
fun *rt.Closure
|
||||||
th *timerHandler
|
th *timerHandler
|
||||||
ticker *time.Ticker
|
ticker *time.Ticker
|
||||||
channel chan bool
|
channel chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timer) start() error {
|
func (t *timer) start() error {
|
||||||
@ -65,7 +65,7 @@ func (t *timer) stop() error {
|
|||||||
return errors.New("timer not running")
|
return errors.New("timer not running")
|
||||||
}
|
}
|
||||||
|
|
||||||
t.channel <- true
|
t.channel <- struct{}{}
|
||||||
t.running = false
|
t.running = false
|
||||||
t.th.running--
|
t.th.running--
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func (th *timerHandler) create(typ timerType, dur time.Duration, fun *rt.Closure
|
|||||||
typ: typ,
|
typ: typ,
|
||||||
fun: fun,
|
fun: fun,
|
||||||
dur: dur,
|
dur: dur,
|
||||||
channel: make(chan bool, 1),
|
channel: make(chan struct{}, 1),
|
||||||
th: th,
|
th: th,
|
||||||
id: th.latestID,
|
id: th.latestID,
|
||||||
}
|
}
|
||||||
|
Načítá se…
x
Odkázat v novém úkolu
Zablokovat Uživatele