Future

Future Type Operation with Scala

Reading Time: 6 minutes Introduction Scala Future represents a result of an asynchronous computation that may or may not be available yet. When we create a new Future, Scala spawns a new thread and executes its code. Once the execution is finished, the result of the computation (value or exception) will be assigned to the Future. Type Future Operations Map When we have a Future instance, we can use the map method to transform its successful result Continue Reading

Completable Future Improvements in Java9

Reading Time: 3 minutes This blog talks about the enhancements and improvements done in Future library as part of Java9 release.

Twitter Future in scala

Reading Time: 2 minutes When we want a simple way to run one or more tasks concurrently in a Scala application. Including a way to handle their results when the tasks finish then we use the scala future. In this blog, we are going to discuss Twitter Future. Twitter futures are more explicit about where computations are executed than the Scala standard library futures. This approach has several advantages over Continue Reading

map(), flatMap() on Futures & Options in scala

Reading Time: 5 minutes In this blog, we would be looking at how map() and flatMap() operations work with Option and Future of scala, literally speaking both Futures and Options are very effective features of scala, A Future lets us have a value from some task on a differnt thread and Option provides us a hand from null of java as using null in scala is seen a very bad approach in Continue Reading

Scala Future Under The Hood

Reading Time: 3 minutes In the previous post, i was discussing about Scala ExecutionContext. As we know, for multithreading we need to maintain thread pools using ExecutionContext and by default ForkJoinPool is used because for accessing “multi core” processor. There are multiple thread pools are available in our java.util.concurrent.Executors utility class and as per our requirement we can create new one also. After all, Scala have concept of Future. Continue Reading

Getting Asynchronous in Scala : Part 2 (macro, reflection and Async library)

Reading Time: 2 minutes “Our patience will achieve more than our force.” – Edmund Burke The thought above tells about the beauty of being patient. One of the most important trait of a programming language is to be patient for the code segments to complete their execution asynchronously. In this blog we will continue with the Async library and some prerequisite associated with it. RECAP In first blog of Continue Reading

Scala Macros -An overview

Reading Time: 4 minutes OVERVIEW In this blog we will understand the basics of Macros and reflection. The main motive of the blog is to lay a foundation for better understanding of the the ‘Async library’. The ‘MAGIC’ of macros -> Macros can be called ‘special functions’ that are called by the compiler during compilation. These functions are special as using macros we can access the compiler API’s which Continue Reading

Employee-Self-Service: Reactive and Non-Blocking Database Access using Play Framework and Anorm – (Part-4)

Reading Time: 2 minutes Last week, We have added Database Access as Reactive and Non-Blocking behaviour in Employee-Self-Service  application. Now we have added some more features. These are following: Achieving, Futures to use more idiomatic error handling. Replaced the embedded JS & CSS libraries with WebJars. Achieving, table pagination and sorting functionality. Before: def list() = Action.async { implicit request => val futureEmpList = scala.concurrent.Future { Employee.list } val timeoutFuture = Promise.timeout("Oops", Continue Reading

Akka Futures: Using For Comprehensions

Reading Time: 3 minutes In my previous post I discussed about composing Futures. I also discussed that Futures are monadic and they can be composed using map or flatmap. Since, for comprehension is just a sugar on top we can use it as well. Lets understand their usage in a bit more detail than my previous post. Using the same example of direct use of Futures and using a Continue Reading