Code Monkey home page Code Monkey logo

Comments (6)

andrewjstone avatar andrewjstone commented on August 27, 2024

Hi @Luminarys,

I'm not sure I follow you here. You can transfer sockets between polls. A socket stays registered until it's deregistered. You use reregister to reuse the socket for this purpose. Note also, that you can call register, reregister, or deregister from any thread where you have a clone of the registrar.

from amy.

Luminarys avatar Luminarys commented on August 27, 2024

The issue (I think?) would be that if I have a poll on thread A, which has some socket registered to it, and I want to transfer this socket to some thread B which has its own poll. If I simply transferred the socket to B and reregistered it without deregistering it on A, would that not cause events for the socket to be reported to the polls on both thread A and B?

from amy.

andrewjstone avatar andrewjstone commented on August 27, 2024

Oh, I see. I never intended sockets to be moved around pollers like that. My use case is that there is a single poller, and events can be routed to different threads where the sockets live via channels. Polling eats threads since it's the only thing they can be used for, and decoding messages and doing work on that thread delays any future polling. However, that's just how I use Amy, and in no way is necessarily "the right way".

I agree that your use case is valid. I don't think you'd want the same socket registered with multiple poll threads. At least with epoll, those events would be reported to both pollers. All that being said, I don't see any real reason why the API can't be changed to just take a reference to the socket in deregister. I think that would fix things so that your use case works, and I don't believe it should cause any other problems. I just looked through git blame to see if there was a specific reason I did it that way and couldn't find any safety issues. It's probably just historical at this point.

from amy.

Luminarys avatar Luminarys commented on August 27, 2024

Unless you're already working on it then, I'll submit a PR with the appropriate changes if that's alright.

from amy.

andrewjstone avatar andrewjstone commented on August 27, 2024

That would be great. Much appreciated.

from amy.

andrewjstone avatar andrewjstone commented on August 27, 2024

Fixed by #23

from amy.

Related Issues (14)

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.