mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +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)
|
||||
ListenUNIX(string, os.FileMode)
|
||||
ListenVirtual(...string) *Server
|
||||
AcquireCtx(*fasthttp.RequestCtx) *Context
|
||||
ReleaseCtx(*Context)
|
||||
Go() error
|
||||
Close() error
|
||||
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
|
||||
func Go() error {
|
||||
return Default.Go()
|
||||
// AcquireCtx gets an Iris' Context from pool
|
||||
// see iris.Handler & ReleaseCtx, 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
|
||||
// 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.RequestCtx = reqCtx
|
||||
return ctx
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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
|
||||
func (s *Framework) Go() error {
|
||||
s.initialize()
|
||||
|
|
Loading…
Reference in New Issue
Block a user