3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

com.twitter.util.Futureのメモ

Last updated at Posted at 2015-06-03

Finagleを使うときに出てくるので、そのメモ書き。
随時更新します。

Future自体は同期的

com.twitter.util.Futureは「計算がまだ完了していない可能性がある」ことを示す単なるモナドなので、非同期処理機構自体は分離されていて、Future 自体は非同期では動かない。

com.twitter.util.Future.applyの挙動を参照。

Future.applyFuture.value

APIドキュメントにも記述があるが、Future.valueは定数(constant value)をFutureでリフトすることを明示的に示すもの。

Future.value("hogefuga")

一方、Future.applyは計算自体をFutureでリフトするもの。これには Exception などをラップする機能がある。

def func: String = throw new Exception
val future = Future(func)
future.isThrow // => true
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?