aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-10-31 09:57:50 +0100
committerMartin Odersky <odersky@gmail.com>2015-10-31 09:57:50 +0100
commit5b2d94a274abe82d26687f1c6ef19fb1d57df2dd (patch)
treefc841753cc74d630814e10e4d8f51bc28f275f4b /src/dotty/tools/dotc/core/Contexts.scala
parentac347485e94061d548bebc794ee133bb1b248a48 (diff)
downloaddotty-5b2d94a274abe82d26687f1c6ef19fb1d57df2dd.tar.gz
dotty-5b2d94a274abe82d26687f1c6ef19fb1d57df2dd.tar.bz2
dotty-5b2d94a274abe82d26687f1c6ef19fb1d57df2dd.zip
Check that access to context base is singlethreaded.
ContextBase is not intended to be threadsafe, We now test that indeed it is not shared by compileUnits calls operating on different threads.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index f9d64b2cc..d5fdba1af 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -611,6 +611,16 @@ object Contexts {
superIdOfClass.clear()
lastSuperId = -1
}
+
+ // Test that access is single threaded
+
+ /** The thread on which `checkSingleThreaded was invoked last */
+ @sharable private var thread: Thread = null
+
+ /** Check that we are on the same thread as before */
+ def checkSingleThreaded() =
+ if (thread == null) thread = Thread.currentThread()
+ else assert(thread == Thread.currentThread(), "illegal multithreaded access to ContextBase")
}
object Context {