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

[Performance] Avoid looping and removing an AtmosphereResource from all available Broadcasters #1885

Closed
jfarcand opened this issue Mar 4, 2015 · 1 comment

Comments

@jfarcand
Copy link
Member

jfarcand commented Mar 4, 2015

When an AtmosphereResource gets destroyed because of a disconnect, we always loops in search for reference to all Broadcaster in DefaultBroadcasterFactory

    @Override
    public void removeAllAtmosphereResource(AtmosphereResource r) {
        // Remove inside all Broadcaster as well.
        try {
            if (store.size() > 0) {
                for (Broadcaster b : lookupAll()) {
                    try {
                        b.removeAtmosphereResource(r);
                    } catch (IllegalStateException ex) {
                        logger.trace(ex.getMessage(), ex);
                    }
                }
            }
        } catch (Exception ex) {
            logger.warn(ex.getMessage(), ex);
        }
    }

When there are thousand of Broadcaster created, this creates a performance botteneck. It would be better to associate a list of Broadcaster to an AtmosphereResource in that case, and make sure when a Broadcaster is destroyed it is also removed from that list.

@jfarcand jfarcand added the 2.3.0 label Mar 4, 2015
@jfarcand jfarcand changed the title [Performance] Avoid looping and removing an AtmosphereResource from all available Broadcaster [Performance] Avoid looping and removing an AtmosphereResource from all available Broadcasters Mar 4, 2015
@thabach
Copy link
Member

thabach commented Mar 4, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants