-
Notifications
You must be signed in to change notification settings - Fork 102
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
add atomic duration type #37
Conversation
Codecov Report
@@ Coverage Diff @@
## master #37 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 2 2
Lines 118 132 +14
=====================================
+ Hits 118 132 +14
Continue to review full report at Codecov.
|
atomic.go
Outdated
// Duration is an atomic wrapper around time.Duration | ||
// https://godoc.org/time#Duration | ||
type Duration struct { | ||
v *Int64 |
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.
would it make more sense to reimplement the underlying int64 bit so we don't have a double-pointer situation?
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.
don't need to reimplement, you can just make this v Int64
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.
Use Int64
instead of a pointer
atomic.go
Outdated
// Duration is an atomic wrapper around time.Duration | ||
// https://godoc.org/time#Duration | ||
type Duration struct { | ||
v *Int64 |
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.
don't need to reimplement, you can just make this v Int64
atomic.go
Outdated
func (d *Duration) Store(s time.Duration) { | ||
d.v.Store(int64(s)) | ||
} | ||
|
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.
after looking at this, i think it might make sense to add Add
, Sub
, CAS
, similar to Int64
, but are atomic
I benchmarked reusing the existing
|
atomic.go
Outdated
// Duration is an atomic wrapper around time.Duration | ||
// https://godoc.org/time#Duration | ||
type Duration struct { | ||
v *Int64 |
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.
Use Int64
instead of a pointer
Before opening your pull request, please make sure that you've:
make test
); and finally,make lint
).Thanks for your contribution!