Sync, Async, Blocking and Non-Blocking | Rock the JVM

preview_player
Показать описание


This video is for programmers of all levels (although I write Scala, naturally). We discuss how some computations are synchronous and blocking, async and blocking, and how we could achieve async non-blocking computations with Akka actors.

Async and non-blocking is what you want. However, even that has its drawbacks. So at the end I show how you can also obtain meaningful values out of a non-blocking computation.

Follow Rock the JVM on:

-------------------------------------------------------------------------
-------------------------------------------------------------------------

///////////////////////////////////////////////

val akkaVersion = "2.6.4"

libraryDependencies ++= Seq(
// akka streams
)
///////////////////////////////////////////////

Timeline:
0:00 intro & requirements
0:47 synchronous, blocking
2:48 asynchronous, blocking
6:20 asynchronous, non-blocking with an actor
11:17 obtaining meaningful values
Рекомендации по теме
Комментарии
Автор

6:38 "Actor ... is not something active. It's just a data structure."

This enlightened me. Brilliant tutorial!

mourikogoro
Автор

Wow.. I read multiple articles without it clicking. I watched your video and felt like I understood it well before it was even over. Thanks a bunch, you're an awesome instructor

cody
Автор

Thank you. But I am a little confused. 15:11 why it’s not blocking. When you call the method you still need to wait the result from another thread right? Forgive my dumbness, I really don’t understand the difference between it and Async non blocking here 4:57.

hrizony
Автор

Awesome video!

One thing that i dont understand is if u take the example of making a HTTP request or call to a database.
I understand that if this call is made asynchronous, the calling thread can continue working, but the Thread waiting for the Future to complete is blocked.

However, if you do this with Actors, the fact doesn't change that by the nature of the HTTP request or database it will take some time to complete the result, so it still blocks the execution
somewhere, right?

yannikschroder
Автор

Thank you, pretty nice like always. Do you have any plans to do a course about ZIO ?

sergeikharchikov
Автор

Thank you for the fantastic work, Daniel! Btw, I'm just wondering if you have any plan to do a course on the akka typed actor and make it available on Udemy or RockTheJVM, as I'm really looking forward to it

mingHiewNN
Автор

in the last line you call which will be executed in one of the global execution context’s threads.

question: how this thread will know about the future completion (which will be completed in the actor’s dispatcher’s thread pool)?

will the dispatcher’s thread somehow notify the globals’s thread that future is completed and is ready to be used in onCompleted(..) block?

waagnermann
Автор

Thanks for these great videos. Do you have any resources on writing and debugging Futures with the ScalaTest framework? I've been trying to use IntelliJ's debugger and evaluate tool to follow the code paths. But I'm not getting through

Krazness
Автор

I am a big fan of your courses on RTJVM. I have a question: “Using actor is asynchronous and non-blocking”, in short, the idea is delegating “blocking thing” to actor’s dispatcher and benefit from its better scheduling, isn’t it?

mr_kurro
Автор

Thank you for this great tutorial. Could you please explain the syntax at 7.45. Specifically the syntax that confuses is me is the "someMessage=> {the function block}". As far as I understand the "=>" operator is used to define types. I.e. you can define the type definition of a function. So what does this syntax mean?

jurevreca
Автор

Very good lesson - interested in finding out why the application does not terminate. Is there some event-loop running?.. if so is there a 'stop' method.
Edit: The actor systems have to be terminated. rootActor.terminate() and promiseResolver.terminte()

ketanpurohit
Автор

Do you think you made non-blocking operation just because you have removed from the third case "Thread.sleep(10000)" line which occured in first two cases? If I put this line to the code-block that will be executed by ActorSystem then there`ll be also a blocking. The only difference is that this blocking will block the dispatcher`s thread, but since dispatcher, global execution context and a main thread are placed on the same machine - then what`s the profit of the model (with promises) that you`ve

waagnermann
Автор

Good video, thank you!

One question, if you allow me. Let's say we have 1 processor, 1 core machine. Will Futures and Asyncs run concurrently, I mean, 1 thread jumps back and forth from one task to another, imitating concurrency, or will it be sequential operations with a fully determined order?

georgezorikov
Автор

Will the main thread not block if message is being sent to Remote actors mail box?

sathisg
Автор

It's an amazing video, thanks :)

unimatrixzro