mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
Export the funcs: AcquireCtx and ReleaseCtx, see previous commit for more
This commit is contained in:
parent
131eddb701
commit
4eee3e5f53
23
iris.go
23
iris.go
|
@ -145,6 +145,8 @@ type (
|
||||||
ListenTLS(string, string, string)
|
ListenTLS(string, string, string)
|
||||||
ListenUNIX(string, os.FileMode)
|
ListenUNIX(string, os.FileMode)
|
||||||
ListenVirtual(...string) *Server
|
ListenVirtual(...string) *Server
|
||||||
|
AcquireCtx(*fasthttp.RequestCtx) *Context
|
||||||
|
ReleaseCtx(*Context)
|
||||||
Go() error
|
Go() error
|
||||||
Close() error
|
Close() error
|
||||||
UseSessionDB(sessions.Database)
|
UseSessionDB(sessions.Database)
|
||||||
|
@ -301,16 +303,24 @@ func (s *Framework) initialize() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go starts the iris station, listens to all registered servers, and prepare only if Virtual
|
// AcquireCtx gets an Iris' Context from pool
|
||||||
func Go() error {
|
// see iris.Handler & ReleaseCtx, Go()
|
||||||
return Default.Go()
|
func AcquireCtx(reqCtx *fasthttp.RequestCtx) {
|
||||||
|
Default.AcquireCtx(reqCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleaseCtx puts the Iris' Context back to the pool in order to be re-used
|
||||||
|
// see iris.Handler & AcquireCtx, Go()
|
||||||
|
func ReleaseCtx(ctx *Context) {
|
||||||
|
Default.ReleaseCtx(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AcquireCtx gets an Iris' Context from pool
|
// AcquireCtx gets an Iris' Context from pool
|
||||||
// see iris.Handler & ReleaseCtx, Go()
|
// see iris.Handler & ReleaseCtx, Go()
|
||||||
func (s *Framework) AcquireCtx(reqCtx *fasthttp.RequestCtx) {
|
func (s *Framework) AcquireCtx(reqCtx *fasthttp.RequestCtx) *Context {
|
||||||
ctx := s.contextPool.Get().(*Context) // Changed to use the pool's New 09/07/2016, ~ -4k nanoseconds(9 bench tests) per requests (better performance)
|
ctx := s.contextPool.Get().(*Context) // Changed to use the pool's New 09/07/2016, ~ -4k nanoseconds(9 bench tests) per requests (better performance)
|
||||||
ctx.RequestCtx = reqCtx
|
ctx.RequestCtx = reqCtx
|
||||||
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseCtx puts the Iris' Context back to the pool in order to be re-used
|
// ReleaseCtx puts the Iris' Context back to the pool in order to be re-used
|
||||||
|
@ -322,6 +332,11 @@ func (s *Framework) ReleaseCtx(ctx *Context) {
|
||||||
s.contextPool.Put(ctx)
|
s.contextPool.Put(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Go starts the iris station, listens to all registered servers, and prepare only if Virtual
|
||||||
|
func Go() error {
|
||||||
|
return Default.Go()
|
||||||
|
}
|
||||||
|
|
||||||
// Go starts the iris station, listens to all registered servers, and prepare only if Virtual
|
// Go starts the iris station, listens to all registered servers, and prepare only if Virtual
|
||||||
func (s *Framework) Go() error {
|
func (s *Framework) Go() error {
|
||||||
s.initialize()
|
s.initialize()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user