Skip to content
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

Refactored EventLoop::timeout_ms to use Duration instead of u64 #48

Merged
merged 1 commit into from Nov 13, 2014

Conversation

Projects
None yet
3 participants
@zslayton
Copy link
Contributor

zslayton commented Nov 12, 2014

Addresses #32. Removed _ms from the method name since the Duration class can represent a range of units.

@zslayton zslayton changed the title Refactored EventLoop::timeout_ms to use Duration instead of uint. Refactored EventLoop::timeout_ms to use Duration instead of u64 Nov 12, 2014

@sschepens

This comment has been minimized.

Copy link

sschepens commented Nov 12, 2014

I was thinking of dropping a pull request for this too, we have to be careful when casting i64 to u64, if it's negative it will give a huve positive u64, maybe we can error o reject negative i64s? or maybe set timeout to 0 when it's negative

@zslayton

This comment has been minimized.

Copy link
Contributor Author

zslayton commented Nov 12, 2014

I considered this -- in honesty, I'm not sure why Duration uses signed values. I'm not sure what it would mean to have a negative duration of time. "Two days ago" is still a duration of two days. Perhaps I should open a ticket upstream to discuss it.

In the meantime, @carllerche, how would you prefer that this case be handled?

@sschepens

This comment has been minimized.

Copy link

sschepens commented Nov 12, 2014

Yeah, i also thought about it, it's kind of misleading to have negative durations but, but golang seems to have them too and there are some use cases where it's actually handy to have negative durations.

@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Nov 12, 2014

For now, if the duration is negative, I would set a 0ms timeout. I would also open an issue upstream. I am going to discuss this issue with @aturon. Besides that, the PR looks good. Thanks

@zslayton

This comment has been minimized.

Copy link
Contributor Author

zslayton commented Nov 12, 2014

I've started a thread on discuss.rust-lang.org. I'll tweak the PR to set a 0ms timeout this evening.

@zslayton zslayton force-pushed the zslayton:master branch from 8f089ee to 3078383 Nov 13, 2014

@carllerche carllerche merged commit 3078383 into carllerche:master Nov 13, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Nov 13, 2014

THanks for the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.