Skip to content

Commit

Permalink
Possibility to override worker thread allocation logic in WebSocketSe…
Browse files Browse the repository at this point in the history
  • Loading branch information
Via Graphs committed Sep 11, 2014
1 parent 05d2e2e commit 726c530
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build
*.svn
*~
target
.idea
*.ipr
*.iml
*.iws
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/java_websocket/server/WebSocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public abstract class WebSocketServer extends WebSocketAdapter implements Runnab

private volatile AtomicBoolean isclosed = new AtomicBoolean( false );

private List<WebSocketWorker> decoders;
protected List<WebSocketWorker> decoders;

private List<WebSocketImpl> iqueue;
private BlockingQueue<ByteBuffer> buffers;
Expand Down Expand Up @@ -184,7 +184,7 @@ public WebSocketServer( InetSocketAddress address , int decodercount , List<Draf
public void start() {
if( selectorthread != null )
throw new IllegalStateException( getClass().getName() + " can only be started once." );
new Thread( this ).start();;
new Thread( this ).start();
}

/**
Expand Down Expand Up @@ -219,9 +219,6 @@ public void stop( int timeout ) throws InterruptedException {

synchronized ( this ) {
if( selectorthread != null ) {
if( Thread.currentThread() != selectorthread ) {

}
if( selectorthread != Thread.currentThread() ) {
if( socketsToClose.size() > 0 )
selectorthread.join( timeout );// isclosed will tell the selectorthread to go down after the last connection was closed
Expand Down Expand Up @@ -422,7 +419,7 @@ public ByteBuffer createBuffer() {
return ByteBuffer.allocate( WebSocketImpl.RCVBUF );
}

private void queue( WebSocketImpl ws ) throws InterruptedException {
protected void queue( WebSocketImpl ws ) throws InterruptedException {
if( ws.workerThread == null ) {
ws.workerThread = decoders.get( queueinvokes % decoders.size() );
queueinvokes++;
Expand Down

0 comments on commit 726c530

Please sign in to comment.