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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.