aboutsummaryrefslogtreecommitdiff
path: root/timer.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-10-23 14:56:01 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-10-23 14:56:01 +0300
commit40e775dce5833385cc180b9b47d2ce60ffcaba15 (patch)
tree2d8da4567a1c237cb6e3f0dd7879a81becad6549 /timer.go
parentProperly implement request read timeout via SetReadDeadline(). Implement resp... (diff)
downloadfasthttp-40e775dce5833385cc180b9b47d2ce60ffcaba15.tar.gz
fasthttp-40e775dce5833385cc180b9b47d2ce60ffcaba15.tar.bz2
fasthttp-40e775dce5833385cc180b9b47d2ce60ffcaba15.zip
Added TimeoutHandler
Diffstat (limited to 'timer.go')
-rw-r--r--timer.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/timer.go b/timer.go
index 8227c7d..4693ecf 100644
--- a/timer.go
+++ b/timer.go
@@ -1,26 +1,20 @@
package fasthttp
import (
- "sync"
"time"
)
-var timerPool sync.Pool
-
-func acquireTimer(timeout time.Duration) *time.Timer {
- tv := timerPool.Get()
- if tv == nil {
+func initTimer(t *time.Timer, timeout time.Duration) *time.Timer {
+ if t == nil {
return time.NewTimer(timeout)
}
-
- t := tv.(*time.Timer)
if t.Reset(timeout) {
- panic("BUG: Active timer trapped into AcquireTimer()")
+ panic("BUG: active timer trapped into initTimer()")
}
return t
}
-func releaseTimer(t *time.Timer) {
+func stopTimer(t *time.Timer) {
if !t.Stop() {
// Collect possibly added time from the channel
// if timer has been stopped and nobody collected its' value.
@@ -29,6 +23,4 @@ func releaseTimer(t *time.Timer) {
default:
}
}
-
- timerPool.Put(t)
}