diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:15 +0000 |
commit | f0e000d7595faddecf4836b8a10452434829540f (patch) | |
tree | 193f2dd3863a337e7bcc43f9f0458ad3d1e3546e /src | |
parent | 7bee6a54009c4978c0e7511b88c59e68aa39683c (diff) | |
download | scala-f0e000d7595faddecf4836b8a10452434829540f.tar.gz scala-f0e000d7595faddecf4836b8a10452434829540f.tar.bz2 scala-f0e000d7595faddecf4836b8a10452434829540f.zip |
Removing some dead code from SyncVar and cleani...
Removing some dead code from SyncVar and cleaning up a little. Closes
#3490, no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/concurrent/SyncVar.scala | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala index 46dc415e1f..5b55be1326 100644 --- a/src/library/scala/concurrent/SyncVar.scala +++ b/src/library/scala/concurrent/SyncVar.scala @@ -6,12 +6,10 @@ ** |/ ** \* */ - - package scala.concurrent - -/** The class <code>SyncVar</code> ... +/** A class to provide safe concurrent access to a mutable cell. + * All methods are synchronized. * * @author Martin Odersky, Stepan Koltsov * @version 1.0, 10/03/2003 @@ -29,24 +27,17 @@ class SyncVar[A] { def get(timeout: Long): Option[A] = synchronized { if (!isDefined) { - try { - wait(timeout) - } catch { - case _: InterruptedException => - } + try wait(timeout) + catch { case _: InterruptedException => () } } - if (exception.isEmpty) { - if (isDefined) Some(value) else None - } else - throw exception.get + if (exception.isDefined) throw exception.get + else if (isDefined) Some(value) + else None } def take() = synchronized { - try { - get - } finally { - unset() - } + try get + finally unset() } def set(x: A) = synchronized { @@ -56,12 +47,6 @@ class SyncVar[A] { notifyAll() } - private def setException(e: Throwable) = synchronized { - exception = Some(e) - isDefined = true - notifyAll() - } - def put(x: A) = synchronized { while (isDefined) wait() set(x) @@ -75,5 +60,5 @@ class SyncVar[A] { isDefined = false notifyAll() } - } + |