Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best-effort drain before shutdown #25

Closed
wants to merge 4 commits into from

Conversation

flozano
Copy link

@flozano flozano commented Nov 19, 2013

Allow to drain the queue and wait until it's empty before shutdown is actually performed. It's a best-effort - shutdown still can return failed notifications, but less likely than with plain shutdown.

final T notification = this.pushManager.getQueue().poll(timeout, timeUnit);

final T notification;
synchronized(pushManager.getQueue()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused; why do you think we need to synchronize on a BlockingQueue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to do a notify() / wait() over an object, synchronized() is needed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, right ;) I was more just wondering why we're doing a wait/notify at all here.

I think I get it now, though, but I'm not totally sure I agree with the timing here. What if the notifyAll happened in the completion listener for the ChannelFuture when we actually write the notification instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved it just at the top of the operationComplete callback. It makes more sense, you are right.

@flozano
Copy link
Author

flozano commented Dec 16, 2013

Any chance of this being merged? or, at least, #20 ?

@jchambers
Copy link
Owner

@flozano Just wrapping up the v0.2 release now and will be starting in on v0.3 features soon.

@flozano flozano closed this Dec 17, 2013
@flozano flozano deleted the drain_before_shutdown branch December 17, 2013 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants