Concurrency with Actors

Let’s rework the file exploration program we created in A Sequential Time-Consuming Problem. The sequential run for the example agility directory took over 66 seconds to run. Let’s implement that problem using actors and see how fast it can run.

The problem nicely fits under the divide-and-conquer approach. Given a starting directory, we want to count the number of files under that directory hierarchy. We can divide that problem into finding the number of files under each subdirectory of the given directory and then combining the result. That, in turn, tells us we have two major parts: one to explore the files and the other to combine the results.

Let’s first work through a high-level design before diving into the code. ...

Get Pragmatic Scala now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.