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

Timers need to work in 1:1 mode #10925

Closed
alexcrichton opened this issue Dec 11, 2013 · 5 comments · Fixed by #11294
Closed

Timers need to work in 1:1 mode #10925

alexcrichton opened this issue Dec 11, 2013 · 5 comments · Fixed by #11294

Comments

@alexcrichton
Copy link
Member

Right now they're heavily based on channels in M:N mode, and this does not easily work at all in 1:1 mode. These abstractions either need to be completely redesigned in order to support being able to work in 1:1 and M:N mode, or they need to get a reasonable implementation in 1:1 mode.

The current best idea that I have for this is to have a global "worker thread" which is an "event loop" for timers and signals. Also remember that whatever design is settled on must have a solution for all platforms.

@alexcrichton
Copy link
Member Author

repurposing this for just timers, signals will be deferred to a new issue.

@alexcrichton
Copy link
Member Author

See #11203 for signals.

@thestinger
Copy link
Contributor

How about adding blocking receive with a timeout to channels and using sleep(reltime) and sleep_until(abstime) in other cases? It would be unnecessary to use a select abstraction if channels had the functionality built-in, and it's a natural operation to perform on a condition variable.

@alexcrichton
Copy link
Member Author

I agree that if channels had timeout functionality built in that much of this might not be necessary, but I personally do not know how to do this efficiently.

For now though, this should probably be discussed in a separate issue. I would still like to have an API with timers as channels, and if we can later upgrade the implementation to use receive with timeouts that's great, but we don't have the ability to do that right now.

@thestinger
Copy link
Contributor

@alexcrichton: There's already a condition variable on native channels as far as I know, so the natural way to expose this functionality is a pthread_cond_timedwait call (or a call to the Vista and later win32 equivalent). The M:N form can do whatever it does now for channels internally, and can be made more efficient later.

Exposing the natural, high-level API makes a lot more sense to me than exposing the lowest common denominator between native and green tasks as they are implemented at the moment. It won't require much implementation work to expose something else, if you don't try to make it faster for green threads than the current timer API.

@bors bors closed this as completed in 7ea063e Jan 23, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2023
add lint [`incorrect_clone_impl_on_copy_type`]

Split off from rust-lang#10788.

Closes rust-lang#10700

----

changelog: new lint [`incorrect_clone_impl_on_copy_type`]
[rust-lang#10925](rust-lang/rust-clippy#10925)
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 a pull request may close this issue.

2 participants