August 2018
Intermediate to advanced
380 pages
10h 2m
English
Now, imagine that our taskHeavy is a handler for an HTTP server. The server is undergoing a heavy load and has 1000 ongoing requests. This means that we need to create 1000 tasks to handle them. With the bunch method, we can define such handling as follows:
(IO.shift *> bunch(1000)(taskHeavy)).unsafeRunSync
Notice that we have encountered another new primitive in this example. It is a shift method that's defined on the IO data type. It is defined as follows:

The shift method is an instruction for the execution to get shifted to an ExecutionContext, which is present as an implicit dependency in scope. Here, we implicitly ...
Read now
Unlock full access