- 授权协议: Apache
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/jolestar/go-commons-pool
- 软件文档: http://jolestar.com/go-commons-pool-and-go-concurrent/
软件介绍
Go Commons Pool 是用 Go 实现的对象池,直接翻译自 Java 版的 Apache Commons Pool.
示例代码:
//use create func
pool := NewObjectPoolWithDefaultConfig(NewPooledObjectFactorySimple(
func() (interface{}, error) {
return &MyPoolObject{}, nil
}))
obj, _ := pool.BorrowObject()
pool.ReturnObject(obj)
//use custom Object factory
type MyObjectFactory struct {
}
func (this *MyObjectFactory) MakeObject() (*PooledObject, error) {
return NewPooledObject(&MyPoolObject{}), nil
}
func (this *MyObjectFactory) DestroyObject(object *PooledObject) error {
//do destroy
return nil
}
func (this *MyObjectFactory) ValidateObject(object *PooledObject) bool {
//do validate
return true
}
func (this *MyObjectFactory) ActivateObject(object *PooledObject) error {
//do activate
return nil
}
func (this *MyObjectFactory) PassivateObject(object *PooledObject) error {
//do passivate
return nil
}
pool := NewObjectPoolWithDefaultConfig(new(MyObjectFactory))
obj, _ := pool.BorrowObject()
pool.ReturnObject(obj)
七周七语言(卷2)
【美】Bruce A. Tate(泰特)、Fred Daoud(达乌德)、Ian Dees(迪斯) / 7ML翻译组 / 人民邮电出版社 / 2016-12 / 59
深入研习对未来编程具有重要意义的7种语言 Lua、Factor、Elixir、Elm、Julia、Idris和MiniKanren 本书带领读者认识和学习7种编程语言,旨在帮助读者探索更为强大的编程工具。 本书延续了同系列的畅销书《七周七语言》《七周七数据库》和《七周七Web开发框架》的体例和风格。 全书共8章,前7章介绍了Lua、Factor、Elm、Elixir、Jul......一起来看看 《七周七语言(卷2)》 这本书的介绍吧!
