-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sdk#898] Add clockmock Start #904
[sdk#898] Add clockmock Start #904
Conversation
pkg/tools/clockmock/mock.go
Outdated
// Start starts mock time to run with the given speed until ctx becomes done. While time is running, current time for | ||
// the mock will be the following: | ||
// mock time := mock start time + (real time duration from the start) * speed + mock duration added with Set, Add | ||
func (m *Mock) Start(ctx context.Context, speed float64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do we need stop method?
- What if Start has called twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Nope, because we have ctx.
- Time will run with (speed-1 + speed-2) speed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this operation be thread-blockable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked with always running time and Mock.SetSpeed
.
pkg/tools/clockmock/mock.go
Outdated
m.lock.RLock() | ||
defer m.lock.RUnlock() | ||
|
||
const tick = 10 * time.Millisecond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should tick be configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, but I can get no usecase why it should.
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
c3b00b5
to
e7a84fc
Compare
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
e7a84fc
to
05977b7
Compare
* Add clockmock Start Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix race issues Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rework Mock.Start to Mock.SetSpeed Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
* Add clockmock Start Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Fix race issues Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> * Rework Mock.Start to Mock.SetSpeed Signed-off-by: Vladimir Popov <vladimir.popov@xored.com> Signed-off-by: Mikhail Avramenko <avramenkomihail15@gmail.com>
Description
Issue link
Relates to #898.
How Has This Been Tested?
Types of changes