summaryrefslogtreecommitdiff
path: root/cask/src
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-09-16 11:08:15 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2019-09-16 11:08:15 +0800
commit2bd2fd997d8898e07d14f23d344008e5a5d9a7a0 (patch)
treeec20121e91b57602f7a808f779f90b5e0ef6620b /cask/src
parent587f6c11d6feeb7d418165a1de652fe2ab410818 (diff)
downloadcask-2bd2fd997d8898e07d14f23d344008e5a5d9a7a0.tar.gz
cask-2bd2fd997d8898e07d14f23d344008e5a5d9a7a0.tar.bz2
cask-2bd2fd997d8898e07d14f23d344008e5a5d9a7a0.zip
cross-build cask.util for Scala.js
Diffstat (limited to 'cask/src')
-rw-r--r--cask/src/cask/util/BatchActor.scala40
-rw-r--r--cask/src/cask/util/Logger.scala18
2 files changed, 0 insertions, 58 deletions
diff --git a/cask/src/cask/util/BatchActor.scala b/cask/src/cask/util/BatchActor.scala
deleted file mode 100644
index 137b852..0000000
--- a/cask/src/cask/util/BatchActor.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-package cask.util
-
-import cask.util.Logger
-
-import scala.collection.mutable
-import scala.concurrent.ExecutionContext
-
-/**
- * A simple asynchrous actor, allowing safe concurrent asynchronous processing
- * of queued items. `run` handles items in batches, to allow for batch
- * processing optimizations to be used where relevant.
- */
-abstract class BatchActor[T]()(implicit ec: ExecutionContext,
- log: Logger) {
- def run(items: Seq[T]): Unit
-
- private val queue = new mutable.Queue[T]()
- private var scheduled = false
- def send(t: => T): Unit = synchronized{
- queue.enqueue(t)
- if (!scheduled){
- scheduled = true
- ec.execute(() => runWithItems())
- }
- }
-
- def runWithItems(): Unit = {
- val items = synchronized(queue.dequeueAll(_ => true))
- try run(items)
- catch{case e: Throwable => log.exception(e)}
- synchronized{
- if (queue.nonEmpty) ec.execute(() => runWithItems())
- else{
- assert(scheduled)
- scheduled = false
- }
- }
-
- }
-}
diff --git a/cask/src/cask/util/Logger.scala b/cask/src/cask/util/Logger.scala
deleted file mode 100644
index 8dc3156..0000000
--- a/cask/src/cask/util/Logger.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package cask.util
-
-import sourcecode.{File, Line, Text}
-
-trait Logger {
- def exception(t: Throwable): Unit
-
- def debug(t: sourcecode.Text[Any])(implicit f: sourcecode.File, line: sourcecode.Line): Unit
-}
-object Logger{
- class Console() extends Logger{
- def exception(t: Throwable): Unit = t.printStackTrace()
-
- def debug(t: Text[Any])(implicit f: File, line: Line): Unit = {
- println(f.value.split('/').last + ":" + line + " " + t.source + " " + pprint.apply(t.value))
- }
- }
-} \ No newline at end of file