本文整理汇总了Scala中java.util.concurrent.LinkedBlockingDeque类的典型用法代码示例。如果您正苦于以下问题:Scala LinkedBlockingDeque类的具体用法?Scala LinkedBlockingDeque怎么用?Scala LinkedBlockingDeque使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkedBlockingDeque类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: LogProcessor
//设置package包名称以及导入依赖的类
package executable
import java.io.FileWriter
import java.text.{DateFormat, SimpleDateFormat}
import java.util.Date
import java.util.concurrent.LinkedBlockingDeque
import exonode.clifton.config.ProtocolConfig
import exonode.clifton.node.SpaceCache
import exonode.clifton.node.entries.ExoEntry
import exonode.clifton.signals.Log.LogType
object LogProcessor extends Thread {
setDaemon(true)
private val LogFile: String = "log.cfv"
private val IntervalTime = 1000
private val MaxLogsCalls = 20
private val logTemplate = ExoEntry[LogType](ProtocolConfig.LogMarker, null)
private val dateFormat: DateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")
private val logs = new LinkedBlockingDeque[LogType]()
private val analyseFile = new SystemAnalyser(2, logs)
override def run(): Unit = {
val space = SpaceCache.getSignalSpace
println("LogProcessor Started...")
analyseFile.start()
while (true) {
val res: Iterable[ExoEntry[LogType]] = space.takeMany(logTemplate, MaxLogsCalls)
if (res.nonEmpty) {
val file: FileWriter = new FileWriter(LogFile, true)
val date: Date = new Date()
for (exoEntry <- res) {
val log = exoEntry.payload
logs.push(log)
file.write(dateFormat.format(date) + ProtocolConfig.LogSeparator + log.logType +
ProtocolConfig.LogSeparator + log.message + "\n")
}
file.close()
} else
Thread.sleep(IntervalTime)
}
}
def main(args: Array[String]): Unit = {
if (args.length > 0)
SpaceCache.signalHost = args(0)
LogProcessor.start()
LogProcessor.join()
}
}
开发者ID:exocute,项目名称:Toolkit,代码行数:57,代码来源:LogProcessor.scala
示例2: EventDeliveryThread
//设置package包名称以及导入依赖的类
package com.twitter.finagle.serverset2.client
import java.util.concurrent.LinkedBlockingDeque
import com.twitter.util.{Monitor, Updatable}
private[client] object EventDeliveryThread
extends Thread("com.twitter.zookeeper.client.internal event delivery") {
private val q = new LinkedBlockingDeque[(Updatable[WatchState], WatchState)]
def offer(u: Updatable[WatchState], s: WatchState) {
q.offer((u, s))
}
override def run() {
while (true) {
val (u, s) = q.take()
try {
u() = s
} catch {
case exc: Throwable => Monitor.handle(exc)
}
}
}
setDaemon(true)
start()
}
开发者ID:wenkeyang,项目名称:finagle,代码行数:28,代码来源:EventDeliveryThread.scala
注:本文中的java.util.concurrent.LinkedBlockingDeque类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论