skip limiting if limit is zero
This commit is contained in:
@@ -85,16 +85,20 @@ func NewLimitedOutOfOrderProcessor(limit int32) (c *LimitedOutOfOrderProcessor)
|
|||||||
|
|
||||||
request := value.Interface().(OperationRequest)
|
request := value.Interface().(OperationRequest)
|
||||||
|
|
||||||
|
if c.processorLimit > 0 {
|
||||||
c.processorLimitCond.L.Lock()
|
c.processorLimitCond.L.Lock()
|
||||||
for atomic.LoadInt32(&c.currentProcessor) > c.processorLimit {
|
for atomic.LoadInt32(&c.currentProcessor) > c.processorLimit {
|
||||||
c.processorLimitCond.Wait()
|
c.processorLimitCond.Wait()
|
||||||
}
|
}
|
||||||
atomic.AddInt32(&c.currentProcessor, 1)
|
atomic.AddInt32(&c.currentProcessor, 1)
|
||||||
c.processorLimitCond.L.Unlock()
|
c.processorLimitCond.L.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
if c.processorLimit > 0 {
|
||||||
defer atomic.AddInt32(&c.currentProcessor, -1)
|
defer atomic.AddInt32(&c.currentProcessor, -1)
|
||||||
defer c.processorLimitCond.Signal()
|
defer c.processorLimitCond.Signal()
|
||||||
|
}
|
||||||
request()
|
request()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user