【问题标题】:How can I replace default thread pool in Dispatch?如何替换 Dispatch 中的默认线程池?
【发布时间】:2013-04-12 03:38:17
【问题描述】:

如何替换 Dispatch 中的默认线程池?我在这里看到https://github.com/dispatch/dispatch/blob/master/futures/src/main/scala/Futures.scala 实例化了CachedThreadPool。我想改用 FixedThreadPool。

【问题讨论】:

    标签: scala scala-dispatch


    【解决方案1】:

    好吧,对不起,伙计们。快速查看 Dispatch 的来源表明我可以通过 setExecutorServiceHttp.configure 传递我的线程执行程序。

    例如

    val pool: ExecutorService = Executors.newFixedThreadPool(4)
    val httpClient: Http = Http.configure(_.setAllowPoolingConnection(true).setFollowRedirects(true).setConnectionTimeoutInMs(1000).setExecutorService(pool))
    

    【讨论】:

    • 唯一的问题是它不起作用。 Dispatch 不使用我传递的对象 :( 我稍后会发布更新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    • 2019-09-13
    • 2019-06-07
    • 2016-11-19
    • 2022-08-20
    相关资源
    最近更新 更多