score:5
there is no need to 'futurise' anything unless that method has asynchronous work to do, i.e. has to wait itself for futures. if the method takes too much time, the caller can always wrap the call into a future
. i would therefore conclude, don't use future
in your api until you really need it.
score:5
there barely exists situation when you may need the future
result but should avoid it because of overhead.
whole future concept is described here
if in short - there is an executioncontext
and it is responsible for all overhead. it receives small closures and is running them as it likes to. the more of such closures exists, the more it should handle.
every action creates new promise
which is shown as future
to you. every means each map
, flatmap
, filter
and so on. each just do operation like foreach
or oncomplete
does not create new promise
but register new closure in the executioncontext
.
all of this is not specifically heavy, but if every your method will be returning a future
it could be a problem.
so just follow reasonable minimalism, but if you need some streamed computation it's usually ok to make every step asynchronous.
Source: stackoverflow.com
Related Query
- When should avoid usage of Future in scala
- Scala for comprehension how to avoid creating of Future when passing results
- What is the formal difference in Scala between braces and parentheses, and when should they be used?
- When and why should one use Applicative Functors in Scala
- How can I avoid mutable variables in Scala when using ZipInputStreams and ZipOutpuStreams?
- MongoDB scala driver: what is a best way to return Future when working with Observer callbacks?
- How should I handle blocking operations when using scala actors?
- Usage of Scala Future in Playframework?
- Why is scala Await.result timing out in repl when passed the same future twice?
- How to avoid adding a 'root' scala sbt project in IntelliJ when defining github dependencies?
- Scala - High heap usage when performed XML.loadFile on large number of files in local scope
- Should I block on a Future - scala
- When should a Scala method def use an explicitly defined return type?
- When should I use Scala method & function
- in scala-akka actor should I open a future when handling a message?
- Why is Scala Future running sequentially when mapped over an Iterator
- Throttling Scala Future blocks when onComplete is used
- Type mismatch when trying to use generic JdbcDriver usage in Slick / Scala
- Scala - How to avoid java.lang.IllegalArgumentException when Row.get(i) would retrieve a null
- In Scala futures, should I make my functions return a Future or return a Try?
- Scala Process never end when applying Future and ThreadPools for Multi-threading
- java.lang.IllegalMonitorStateException when testing scala future
- How to avoid boxing when composing numbers in base 3 in Scala
- Scala Spark : trying to avoid type erasure when using overload
- Scala Future is not properly called when using implicit class
- Scala Future does not return anything when allocating too much memory
- When should I use a Scala class and when to use Scala object in IDE?
- Cleanest way in Scala to avoid nested ifs when transforming collections and checking for error conditions in each step
- Underscore usage when passing a function in Scala
- Future in scala cann't run asynchronously when the future number larger than cpu core number
More Query from same tag
- Scala Breeze Beta distribution parameter estimation
- Select max common Date from differents DataFrames (Scala Spark)
- Very simple call cannot be made using http4s
- Spark scala split string and convert to dataframe with two columns
- spark-shell scale Filter timestamp column, take average of exchange rate and aggregate on date
- How to sequence Play Enumerators without interleaving?
- Scala Lift - SBT compilation error (Sources not found)
- How to extract values from JSON-encoded column?
- Play framework JavaScript function as scala template parameter
- Scala slow hashmap
- Converting CassandraTableScanRDD org.apache.spark.rdd.RDD
- Group By error 33 : wrong number of parameter
- how to filter and extract case class objects from big flat csv files using shapeless?
- How to implement STTP SSL requests with HttpClientZioBackend? (SCALA/ZIO)
- Weird nested structural type in generics
- Akka Kafka Producersettings : overloaded method value apply with alternatives:
- order of events when using akka streams
- Why was getMonth deprecated on java.sql.Date and java.util.Date
- Scala`s <> operator meaning
- How to convert jsonAST.Jint to int
- How to de duplicate rows in spark dataframe based on custom logic?
- spark withcolumn create a column duplicating values from existining column
- Errors get thrown before evaluating the function in Scala
- Set java options for running playframework project in sbt
- Scala use ML to find outliers in a Dataframe
- Scala syntax for do-nothing function?
- Getting info on Groovy functions (name, signature, body code)
- How does Scala attain parallelism?
- Is the Scala Breeze package thread safe for use in Spark Dataframe processing?
- Populating a list with results from queue within a while loop in scala