Skip to content

NetworkBehaviour event queue and polling #5825

Answered by elenaf9
b-zee asked this question in Q&A
Discussion options

You must be logged in to vote

However, I can't really verify/understand this pattern in Swarm::poll_next_event.

It's because poll_next always continues from the top after any events in pool (e.g. new connection events) or events on established connections. And then all behaviors are polled again. Does that make sense?

I assume technically the solution is to use a channel which the events are pushed on. If this channel is polled in poll then it will register a waker for whenever something is pushed in the channel. And so based on the above comment by Thomas, that's needed if events are queued outside of the NetworkBehaviour trait methods impls.

Regarding the last part of queuing events outside of the NetworkBehavior

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@b-zee
Comment options

@elenaf9
Comment options

Answer selected by b-zee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants