Coder Social home page Coder Social logo

Comments (9)

rrichardson avatar rrichardson commented on June 15, 2024

I should note that the iterator could probably be made into the Selector as well.

from mio.

dtantsur avatar dtantsur commented on June 15, 2024

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.

rrichardson avatar rrichardson commented on June 15, 2024

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.

dtantsur avatar dtantsur commented on June 15, 2024

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.

rrichardson avatar rrichardson commented on June 15, 2024

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.

dtantsur avatar dtantsur commented on June 15, 2024

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.

rrichardson avatar rrichardson commented on June 15, 2024

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.

dtantsur avatar dtantsur commented on June 15, 2024

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.

carllerche avatar carllerche commented on June 15, 2024

We are going to be keeping Poll. I think it is useful as a standalone construct.

from mio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.