Skip to content

Instantly share code, notes, and snippets.

@timperrett
Created December 10, 2010 12:52
Show Gist options
  • Select an option

  • Save timperrett/736169 to your computer and use it in GitHub Desktop.

Select an option

Save timperrett/736169 to your computer and use it in GitHub Desktop.
def doSync[F](f: => F): F = S.session match {
case Full(s) => {
// lock the session while the Var-specific lock object is found/created
val lockName = name + VarConstants.lockSuffix
val lockObj: Object = s.synchronized {
localGet(s, lockName) match {
case Full(lock: Object) => lock
case _ => val lock = new Object
localSet(s, lockName, null)
lock
}
}
// execute the query in the scope of the lock obj
lockObj.synchronized {
f
}
}
case _ => f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment