
scala.concurrent.stm.impl.STMSelector.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-stm_sjs1_2.13 Show documentation
Show all versions of scala-stm_sjs1_2.13 Show documentation
A library for Software Transactional Memory in Scala
The newest version!
package scala.concurrent.stm.impl
import scala.concurrent.stm.impl.STMImpl.instance
// the JS version support default and instance based selection
trait STMSelector {
/** Installs `impl` as the system-wide STM implementation if no `STMImpl`
* has yet been chosen, or verifies that `impl` is equal to the previously
* selected instance, throwing `IllegalStateException` if an STM
* implementation has already been selected and `impl != instance`
*/
def select(impl: STMImpl): Unit = {
explicitChoice = impl
if (impl != instance) {
throw new IllegalStateException(
"unable to select STMImpl " + impl + ", " + instance + " already installed")
}
}
/** May be an STMImpl, or null */
@volatile private var explicitChoice: STMImpl = null
private[impl] def createInstance(): STMImpl = {
var choice = explicitChoice
if (choice == null) {
choice = new scala.concurrent.stm.ccstm.CCSTM
}
choice
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy