future

    6熱度

    2回答

    下面的例子是從C++ async tutorial採取: #include <future> #include <iostream> #include <vector> int twice(int m) { return 2 * m; } int main() { std::vector<std::future<int>> futures; for(int i =

    1熱度

    1回答

    我已閱讀Netty指南,它不會在ChannelFuture上解釋太多。我很困惑,爲什麼它不會造成僵局。 1.它教我如此啓動一臺服務器。 ServerBootstrap sb = new ServerBootstrap(); sb.group(bossGroup, workerGroup); sb.channel(NioServerSocketChannel.class);

    1熱度

    1回答

    當我試圖流期貨爲的Html(在斯卡拉劇2.5.2)的想法是,它們會呈現在屏幕上時,期貨完整。所以我會流一來源作爲字符串這樣的: def oneFuture = Action { request => val source1: Source[String, NotUsed] = fromFuture(sc.makeServiceCall("async1")) Ok.chunked

    0熱度

    1回答

    我試圖找出如何重新排隊已超時(我使用uvloop和aiodns模塊)一些異步DNS請求異常後。 下面是我設置的循環與代碼: asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) loop = asyncio.get_event_loop() resolver = aiodns.DNSResolver(loop=loop) sem =

    1熱度

    1回答

    我必須在斯卡拉的2D列表上執行一些操作,並且我正在試圖平行該任務。 目前我有三個期貨,其中每個都需要N行矩陣並執行必要的計算。它是這樣寫的: val future1: Future[List[Int]] = Future { makeCalculations(0, 5) } val future2: Future[List[Int]] = Future { makeCalculations(6,

    0熱度

    2回答

    我有一個Future lazy val,它獲得一些提交未來操作的對象和函數。 class C { def printLn(s: String) = println(s) } lazy val futureC: Future[C] = Future{Thread.sleep(3000); new C()} def func(s: String): Unit = { futu

    0熱度

    2回答

    我正在實施一種方法,使用Vertx檢查數據庫中是否存在某個值,並使用Handler和AsyncResult。 我想知道哪一個是最好的做法: 選項1:如果沒有發現,處理程序與succeededFuture但結果爲FALSE: public void checkExistence (..., String itemToFind, Handler<AsyncResult<Boolean>> result

    0熱度

    1回答

    我是新來斯卡拉,我試圖讓期貨的手柄和多線程 我有一個程序的版本的SingleThreaded,使得在矩陣的一些計算 SingleThreadCalc { def run(matrix : Seq[Seq[Double]]) : Future[Seq[Seq[Double]] = Future{doMath(matrix)} } 我現在想要的是製作一個多線程版本。 是否足夠讓一個Ex

    0熱度

    1回答

    我有未來[MyType的],我需要的MyType的值傳遞給它返回SEQ方法[未來[MyType的],的問題,所以基本簽名是: val a: Seq[Future[MyType]] = ... getValue(t: MyType): Seq[Future[MyType]] = {...} 我想要的值傳遞給的getValue。我想是這樣的: val b:Seq[Future[MyType]]

    0熱度

    1回答

    我有一些服務回報CompletableFutures這樣 Set<CompletableFuture<String>> futures = service.getSomething(); for (CompletableFuture<String> future : futures) { System.out.println(future.get()); } 該代碼打印值迭代順