Created
December 10, 2010 12:52
-
-
Save timperrett/736169 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
| 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