2017-03-15 1 views
1

scala.concurrent.Future 대신 akka.http.scaladsl.util.FastFuture를 사용해야합니까?scala.concurrent.Future 대신 akka.http.scaladsl.util.FastFuture를 사용해야합니까?

코멘트는 말한다 : 나는 Future.apply, Future.successful 또는 Future.failed를 사용해야하는 경우에

/** 
* Provides alternative implementations of the basic transformation operations defined on [[scala.concurrent.Future]], 
* which try to avoid scheduling to an [[scala.concurrent.ExecutionContext]] if possible, i.e. if the given future 
* value is already present. 
*/ 

내가 특히 어떤 성능 향상을받을 수 있나요?

정확히 두 구현의 차이점은 무엇입니까?

+0

차이점은 'FastFuture'에서 시작하여'map','filter' 등의 조합 메소드 중 하나를 호출하고 기본'Future'가 이미 완료 되었다면 결합 호출은 직접 실행됩니다 호출자 스택에. – jrudolph

+0

이미 완료된 Future가 'Try'와 매우 유사하다고 말할 수 있습니다. 여전히 계류중인'Future'의 경우, 그것은'Future'와 같은 것입니다 : 모든 combinator 호출은 암묵적으로 전달 된'ExecuteContext'를 사용하여 실행될 것입니다. – jrudolph

+0

왜 변경 사항이'scala.concurrent.Future'에 병합되지 않습니까? –

답변

0

본질적으로 FastFutureExecutionContextFuture 제출을 우회하여 (이미 성공했는지 여부) 완료 될 경우에 대비하여 ExecutionContext에 제출할 수 있습니다.

간단히 말해서, 성능 향상을 얻을 수 있습니다. 그것들이 무시할 수 있을지 상당한지 여부는 개발중인 응용 프로그램에 달려 있습니다.

이러한 개선 사항을 스칼라 2.12에 포함시킬 계획이 있다고 생각하지만, 구체적인 내용은 들어 본 적이 없다.

관련 문제