Skip to content

Conversation

@yunlong0928
Copy link

之前的写法:

b.mu.Unlock()
//如果此时新加入了一个expiration位于currentTime下个tick间隔内的timer,记为A
//则A还是会定位到这个bucket,但是不会将bucket推入delayqueue,因为bucket的expiration不为-1
b.SetExpiration(-1) // TODO: Improve the coordination with b.Add()
//如果再之后,当前tick间隔内没有新的timer进来,那么A就被遗忘了

解决方案:

b.SetExpiration(-1)
b.mu.Unlock()
//这样即使再有expiration位于currentTime下个tick间隔内的timer加进来,bucket也会被推入delayqueue

@yunlong0928 yunlong0928 changed the title Fix bucket.Flush Fix bucket.Flush and the not thread-safe issue between tw.add and tw.advanceClock Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant