Skip to content

Make UvTImer selectable and implement recv_timeout #9746

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

Closed
wants to merge 3 commits into from

Conversation

flaper87
Copy link
Contributor

@flaper87 flaper87 commented Oct 7, 2013

NOTE This is not ready to be merged, it's a work in progress idea.

I'm looking for feedback on the SelectInner implementation for UvTimer. The idea I came up with is to have a select_then method that takes a callback and calls it right after starting the watcher. The reason why this is needed is that libuv IO has to happen within it's own scheduler and before switching back to the main scheduler the timer has to have completed or stopped.

In sleep_then callback, users will be able to either deschedule the task themselves or sleep on multiple 'selectable' objects and wake up the task at the first event.

Thoughts?

This is part of #3015

@@ -24,6 +29,13 @@ pub fn sleep(msecs: u64) {
timer.sleep(msecs)
}

/// Sleep the current task for `msecs` milliseconds.
pub fn sleep_uv(msecs: u64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different to normal sleep? Can the difference please be documented?

(Also, I believe a goal for std::rt::io is to be independent of the event loop that it is running on, so a function with a name like sleep_uv seems like it would be exposing too many implementation details of the libuv event loop. That said, I'm no expert on the RT, and I haven't looked at the implementations at all.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be removed, I added a comment in the UvTimer implementation of this method. It was part of some experiments I was doing, sorry for the confusion here, I'll get rid of it.

@olsonjeffery
Copy link
Contributor

I have 4e0ae61e1 checked out in my local repo..

got this doing make check-stage1-std1:

test rt::io::option::test::test_option_writer_error ... ok
test rt::io::timer::test::test_io_timer_sleep_uv_simple ... ok
test rt::io::timer::test::test_io_timer_sleep_uv_standalone ... ok
test rt::io::timer::test::test_recv_timeout ... ok
task '<unnamed>' failed at 'assertion failed: p.recv_timeout(1000).is_none()', /Users/jeff/src/rust/src/libstd/rt/io/timer.rs:193


Instead of the poems I had hoped for, there came only a shuddering blackness
and ineffable loneliness; and I saw at last a fearful truth which no one had
ever dared to breathe before — the unwhisperable secret of secrets — The fact
that this city of stone and stridor is not a sentient perpetuation of Old New
York as London is of Old London and Paris of Old Paris, but that it is in fact
quite dead, its sprawling body imperfectly embalmed and infested with queer
animate things which have nothing to do with it as it was in life.

fatal runtime error: assertion failed: exit_status
/bin/sh: line 1: 39722 Abort trap: 6           x86_64-apple-darwin/stage1/test/stdtest-x86_64-apple-darwin --logfile tmp/check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-std.log --test --bench --save-metrics tmp/check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-std-metrics.json
make: *** [tmp/check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-std.ok] Error 134
bash-3.2$

@alexcrichton
Copy link
Member

Closing due to inactivity, and I also think that this may be superseded by #10083. We may still want a different form of selectability for timers, but we at least have some methods of using timers as ports now.

@flaper87
Copy link
Contributor Author

Not sure this is already implemented, and I was going to get back to it. This PR is about implementing Select and SelectInner for the Timer, which will allow for blocking on recv up to N msecs and return when either the port receives a message or the timer expires.

@olsonjeffery
Copy link
Contributor

@flaper87 this branch is dead, more or less, due to age and the points @alexcrichton makes above. If we want to proceed, do it on a new PR. Thanks.

@flaper87 flaper87 deleted the issue/9195 branch October 29, 2013 15:47
@flaper87
Copy link
Contributor Author

@olsonjeffery yeah, just wanted to drop a comment explaining why I think it's not fully implemented! Will do it in a new PR!

flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 21, 2022
Fix ICE in `redundant_allocation`

changelog: Fix ICE in `redundant_allocation`

Closes rust-lang#9746, the original issue was fixed already, this gets the one in rust-lang/rust-clippy#9746 (comment)
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.

4 participants