Comments (9)
I should note that the iterator could probably be made into the Selector as well.
from mio.
Let me repeat my comment here: EventLoop is too heavyweight if you need e.g. to multiplex 2 sockets for reading. Also, poller is a commonly used abstraction IMO, so people will expect to find it.
from mio.
That's fine. But use Selector instead of Poll. They are effectively
identical.
On Nov 14, 2014 3:15 AM, "Dmitry Tantsur" [email protected] wrote:
Let me repeat my comment here: EventLoop is too heavyweight if you need
e.g. to multiplex 2 sockets for reading. Also, poller is a commonly used
abstraction IMO, so people will expect to find it.—
Reply to this email directly or view it on GitHub
#50 (comment).
from mio.
I would say Selector API is a bit more specific. E.g. passing in a mutable pointer to Events does not look user-friendly, IMO it breaks encapsulation.
from mio.
I'm failing to see how passing something a function a mutable container to
be filled breaks encapsulation.
It actually offers tighter control over how many events one would want to
receive per pass, which is often necessary.
Also, you get your iterator wish, because after select completes, you are
welcome to iterate over it, because its your container.
On Fri, Nov 14, 2014 at 10:10 AM, Dmitry Tantsur [email protected]
wrote:
I would say Selector API is a bit more specific. E.g. passing in a mutable
pointer to Events does not look user-friendly, IMO it breaks encapsulation.—
Reply to this email directly or view it on GitHub
#50 (comment).
“Science is the great antidote to the poison of enthusiasm and
superstition.” -- Adam Smith
from mio.
I hoped that after leaving C++ development I will never end up using
type result;
get_foo(&result);
instead of
type result = get_foo();
(pseudo-c++).
This API does not look like something I encountered in Rust up until now.
What I expect from a polling object is actually like this https://docs.python.org/2/library/select.html#select.poll.poll
from mio.
There is no way to have the 2nd one with out an alloc at every iteration.
(Unless you give it a mutable vector early on that it keeps returning an
immutable reference to) I'm okay with that.
But even then, you still don't need Poll. There is no reason the Selector
interface can be made to do that.
On Nov 14, 2014 11:33 AM, "Dmitry Tantsur" [email protected] wrote:
I hoped that after leaving C++ development I will never end up using
type result;
get_foo(&result);instead of
type result = get_foo();
(pseudo-c++).
This API does not look like something I encountered in Rust up until now.
What I expect from a polling object is actually like this
https://docs.python.org/2/library/select.html#select.poll.poll—
Reply to this email directly or view it on GitHub
#50 (comment).
from mio.
There is no way to have the 2nd one with out an alloc at every iteration.
You mean that Rust can't return values on stack? I'm sure it can.
What I want is (pseudo-Rust):
fn poll(&self) -> &[Event] {
let len = nix::epoll(&mut self.events);
self.events[..len] // not sure about slice syntax here
}
No allocations here IIUC. This will allow exactly the code I expect:
for event in poller.poll().iter() {
// process
}
Of course I don't insist it should be called 'Poll'. I'm completely sure that making all users write boilerplate code won't benefit mio.
from mio.
We are going to be keeping Poll
. I think it is useful as a standalone construct.
from mio.
Related Issues (20)
- Continue or break while would_block error in tcpStream read loop? HOT 3
- any workaround to allow registering to different Poll? HOT 8
- A way to add EPOLLPRI event type to the epoll selector HOT 7
- Master doc page out of date? HOT 2
- Windows named pipes hits unreachable code during read operation HOT 1
- Can TcpStream be read from a different thread? HOT 1
- Exposing `AsRawHandle` on `Registry` HOT 5
- build failed with wasm-pack HOT 1
- Wait for messages in the error queue HOT 6
- Setup WASM/WASI CI
- get any errors when i use `wasm-pack` command by `mio` HOT 4
- Need switch to not use eventfd on `target_os = "linux"` HOT 4
- Add ESP-IDF framework support
- IoRing support for windows HOT 1
- Has waker check doesn't work with try_cloned Registries HOT 1
- compile time error inside `poll.rs` HOT 3
- poll: Optimize locks and allocations in the critical path
- Poll(2) implementation follow-ups
- Official ESP-IDF framework support HOT 3
- Make `CompletionPort` public? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mio.