Skip to content
This repository has been archived by the owner on Nov 30, 2019. It is now read-only.

Commit

Permalink
Init all object state in ConnectionManager constructor before startin…
Browse files Browse the repository at this point in the history
…g thread in constructor that accesses object's state
  • Loading branch information
srowen committed Jan 27, 2015
1 parent 0497ea5 commit c4dec3b
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ private[nio] class ConnectionManager(
// to be able to track asynchronous messages
private val idCount: AtomicInteger = new AtomicInteger(1)

private val writeRunnableStarted: HashSet[SelectionKey] = new HashSet[SelectionKey]()
private val readRunnableStarted: HashSet[SelectionKey] = new HashSet[SelectionKey]()

private val selectorThread = new Thread("connection-manager-thread") {
override def run() = ConnectionManager.this.run()
}
selectorThread.setDaemon(true)
// start this thread last, since it invokes run(), which accesses members above
selectorThread.start()

private val writeRunnableStarted: HashSet[SelectionKey] = new HashSet[SelectionKey]()

private def triggerWrite(key: SelectionKey) {
val conn = connectionsByKey.getOrElse(key, null)
if (conn == null) return
Expand Down Expand Up @@ -232,7 +234,6 @@ private[nio] class ConnectionManager(
} )
}

private val readRunnableStarted: HashSet[SelectionKey] = new HashSet[SelectionKey]()

private def triggerRead(key: SelectionKey) {
val conn = connectionsByKey.getOrElse(key, null)
Expand Down

0 comments on commit c4dec3b

Please sign in to comment.