Comments (6)
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.
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.
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.
Unless you're already working on it then, I'll submit a PR with the appropriate changes if that's alright.
from amy.
That would be great. Much appreciated.
from amy.
Fixed by #23
from amy.
Related Issues (14)
- Add Deregister and Reregister operations HOT 1
- More Examples and Docs HOT 2
- Allow Polling on channel receivers HOT 1
- Detail the type of notification being returned HOT 1
- Consider making polling not oneshot
- Put a newtype wrapper around event ids
- Take `Duration` instead of `usize` (ms) for time parameters
- Consider using the high 8 bits of ID as a type
- Use u64 instead of usize for IDs and timeouts
- ChannelError type private HOT 1
- timerfd code fails to compile on 32 bit systems HOT 3
- Edge triggered events in kqueue HOT 5
- Dependency on nix < 0.12 presents compilation on aarch64-unknown-linux-musl
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 amy.