diff options
author | Li Haoyi <haoyi.li@databricks.com> | 2019-09-16 22:31:03 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.li@databricks.com> | 2019-09-16 22:31:03 +0800 |
commit | bfe26d5a9705011359658c45b364e9b65ce697b5 (patch) | |
tree | 656565b3d147b1837d4cfc1d949e7af8c250f16c /cask/util/src-jvm/cask/util/Scheduler.scala | |
parent | 84ea971b1261919aca7b31635ddc7d0dca830fea (diff) | |
download | cask-bfe26d5a9705011359658c45b364e9b65ce697b5.tar.gz cask-bfe26d5a9705011359658c45b364e9b65ce697b5.tar.bz2 cask-bfe26d5a9705011359658c45b364e9b65ce697b5.zip |
Provide a simple builtin websocket client in `cask.WsClient`
Harmonize the actor-based APIs of `cask.WsClient`/`cask.WsHandler`/`cask.WsActor`, letting them share the same set of `cask.Ws` events
The default implementation of `cask.WsClient` on the JVM spawns one thread per connection, and doesn't really scale to large numbers of connections. For now we just continue using AsyncHttpClient in the load tests. Wrapping AsyncHttpClient in a nice API is TBD
Diffstat (limited to 'cask/util/src-jvm/cask/util/Scheduler.scala')
-rw-r--r-- | cask/util/src-jvm/cask/util/Scheduler.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cask/util/src-jvm/cask/util/Scheduler.scala b/cask/util/src-jvm/cask/util/Scheduler.scala new file mode 100644 index 0000000..74db37e --- /dev/null +++ b/cask/util/src-jvm/cask/util/Scheduler.scala @@ -0,0 +1,16 @@ +package cask.util + +import java.util.concurrent.{Executors, TimeUnit} + +object Scheduler{ + val scheduler = Executors.newSingleThreadScheduledExecutor() + def schedule(millis: Long)(body: => Unit) = { + scheduler.schedule( + new Runnable { + def run(): Unit = body + }, + millis, + TimeUnit.MILLISECONDS + ) + } +}
\ No newline at end of file |