Created
May 9, 2011 04:03
-
-
Save SpaceManiac/962034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.glowstone.net; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* A list of all the sessions which provides a convenient {@link #pulse()} | |
* method to pulse every session in one operation. | |
* @author Graham Edgecombe | |
*/ | |
public final class SessionRegistry { | |
/** | |
* A list of the sessions. | |
*/ | |
private final List<Session> sessions = new ArrayList<Session>(); | |
/** | |
* Pulses all the sessions. | |
*/ | |
public void pulse() { | |
synchronized (sessions) { | |
for (Session session : sessions) { | |
session.pulse(); | |
} | |
} | |
} | |
/** | |
* Adds a new session. | |
* @param session The session to add. | |
*/ | |
public void add(Session session) { | |
synchronized (sessions) { | |
sessions.add(session); | |
} | |
} | |
/** | |
* Removes a session. | |
* @param session The session to remove. | |
*/ | |
public void remove(Session session) { | |
synchronized (sessions) { | |
sessions.remove(session); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment