forked from p93542168/wheat-cache
feat(event): feat the io of judgement function
This commit is contained in:
parent
83bf49ec17
commit
5275be2b8e
|
@ -18,7 +18,7 @@ type EventWorkFunc func() (interface{}, error)
|
||||||
type DriverInterface interface {
|
type DriverInterface interface {
|
||||||
Get() *Event
|
Get() *Event
|
||||||
Put(event *Event)
|
Put(event *Event)
|
||||||
GetLength() int
|
GetLengthJudge() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProduceInterface interface {
|
type ProduceInterface interface {
|
||||||
|
|
|
@ -137,8 +137,12 @@ func (d *Driver) Put(event *Event) {
|
||||||
d.queue <- event
|
d.queue <- event
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetLength() int {
|
func (d *Driver) GetLengthJudge() bool {
|
||||||
return len(d.queue)
|
// 自动对当前的最大io数量进行判断
|
||||||
|
if len(d.queue) > d.maxQueueSize * 1/2{
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDriver 新建 Driver
|
// NewDriver 新建 Driver
|
||||||
|
|
Loading…
Reference in New Issue