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

  Рет қаралды 12,965

Rock the JVM

Rock the JVM

Күн бұрын

Пікірлер: 35
@mourikogoro9709
@mourikogoro9709 4 жыл бұрын
6:38 "Actor ... is not something active. It's just a data structure." This enlightened me. Brilliant tutorial!
@rockthejvm
@rockthejvm 4 жыл бұрын
So glad it clicked!
@cody8708
@cody8708 4 жыл бұрын
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
@rockthejvm
@rockthejvm 4 жыл бұрын
Thank you!
@hrizony7847
@hrizony7847 5 ай бұрын
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.
@adityaprasad465
@adityaprasad465 10 күн бұрын
Depends on what "you" means here. The println has to wait, but the thread will keep running. For example, if the next line said println("hi"), then it could execute even before the promise is fulfilled.
@waagnermann
@waagnermann 4 жыл бұрын
in the last line you call asyncNonBlockingResult.onComplete(...) 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?
@rockthejvm
@rockthejvm 4 жыл бұрын
Something like that. The execution context also has a small scheduler which is able to run callbacks and Future transformations like map/flatMap.
@yannikschroder3381
@yannikschroder3381 3 жыл бұрын
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?
@rockthejvm
@rockthejvm 3 жыл бұрын
We're concerned with whether the thread itself is waiting. If you fire the call and the thread moves to other tasks, it's not blocked.
@francis.joseph
@francis.joseph 2 жыл бұрын
this is not getting
@hrizony7847
@hrizony7847 5 ай бұрын
⁠​⁠​⁠​⁠@@rockthejvmin line28 you said the blocking aspect of the program is that there is another thread that is blocking. IIUC, that doesn’t block the main calling thread. So as far as call thread itself concerned, it is nonblocking right? In the last example, if I also let thread sleep, for example in line33. that means that thread that will work on the action in the future will be blocked. In that sense there is also a blocking aspect in this solution? So I’m confused and it looks like whether to have thread.sleep is what determines one blocking or non-blocking?
@mingHiewNN
@mingHiewNN 4 жыл бұрын
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
@rockthejvm
@rockthejvm 4 жыл бұрын
On the roadmap - it will take some time as the material is massive, so thanks for the patience!
@Krazness
@Krazness Жыл бұрын
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
@jurevreca9229
@jurevreca9229 2 жыл бұрын
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?
@rockthejvm
@rockthejvm 2 жыл бұрын
Check the Scala at Light Speed video that talks about functions, we have everything there.
@nao_concordo
@nao_concordo 4 жыл бұрын
Thank you, pretty nice like always. Do you have any plans to do a course about ZIO ?
@rockthejvm
@rockthejvm 4 жыл бұрын
Perhaps - shout in the comments if anyone else needs ZIO!
@shef9192
@shef9192 4 жыл бұрын
Zio +
@nullptr7
@nullptr7 3 жыл бұрын
Yes zio would be great 🔥
@ketanpurohit9086
@ketanpurohit9086 3 жыл бұрын
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()
@rockthejvm
@rockthejvm 3 жыл бұрын
There's the execution context running, which needs stopping.
@waagnermann
@waagnermann 4 жыл бұрын
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 shown?))))))))
@rockthejvm
@rockthejvm 4 жыл бұрын
The sleeps are just for illustration, I think you got the idea.
@georgezorikov3075
@georgezorikov3075 4 жыл бұрын
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?
@rockthejvm
@rockthejvm 4 жыл бұрын
Nope, still concurrent. The OS can schedule and interrupt threads on the same physical core at (almost) any time, so the same conditions for multithreading still apply.
@mr_kurro
@mr_kurro 3 жыл бұрын
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?
@rockthejvm
@rockthejvm 3 жыл бұрын
You're not delegating anything to an actor - you're just sending it a message. The internal logic of the actor will run at some point, on some thread. The end goal is not necessarily better thread scheduling (although that is also true) but better isolation of logic in your application, without needing to care about threads at all.
@victorpre
@victorpre 2 жыл бұрын
another great video
@sathisg
@sathisg 4 жыл бұрын
Will the main thread not block if message is being sent to Remote actors mail box?
@rockthejvm
@rockthejvm 4 жыл бұрын
Never - message sending is fully non-blocking
@unimatrixz3ro226
@unimatrixz3ro226 3 жыл бұрын
It's an amazing video, thanks :)
@Gohel95
@Gohel95 4 жыл бұрын
Thanks💕💕💕
@coffeezealot8535
@coffeezealot8535 4 жыл бұрын
haha nice parrot
How to create your own String interpolator in Scala | Rock the JVM
13:36
Self-Types in Scala - the Why and the How | Rock the JVM
14:57
Rock the JVM
Рет қаралды 8 М.
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Non-blocking IO under the Hood
1:00:08
SQUER Solutions
Рет қаралды 6 М.
Objects and Companions in Scala | Rock the JVM
14:01
Rock the JVM
Рет қаралды 9 М.
Akka Typed: Stateful and Stateless Actors | Rock the JVM
19:11
Rock the JVM
Рет қаралды 7 М.
Adam Warski - Concurrency in Scala and on the JVM
43:49
Scala Days Conferences
Рет қаралды 2,2 М.
What the Functor? | Functors in Scala | Rock the JVM
24:43
Rock the JVM
Рет қаралды 12 М.
Blocking or Non-Blocking API calls?
13:22
CodeOpinion
Рет қаралды 10 М.
Contravariance in Scala: Why Is It So Hard? | Rock the JVM
16:24
Rock the JVM
Рет қаралды 15 М.