Book Image

Rake Task Management Essentials

By : Andrey Koleshko
Book Image

Rake Task Management Essentials

By: Andrey Koleshko

Overview of this book

Table of Contents (18 chapters)
Rake Task Management Essentials
About the Author
About the Reviewers

Thread safety of multitasks

Rake's internal data structures are thread-safe, so we don't have to do extra synchronization for the benefit of Rake. However, if we have shared variables or resources (for example, the database or files) and the parallel tasks are simultaneously performing operations under them, we must prevent race conditions with additional effort. Basically, this requires using additional tools to synchronize the data.

You've already seen the problem with the @a variable in the previous example. To get rid of the problem, we have to ask the set_b task to wait for the set_a task. However, as we don't have public access to their threads, we can't to do this, so they can't be executed in parallel. In the example, multitasking is redundant and a sequential execution will be more appropriate there; be careful when using multitasking because of this particular reason.


Unfortunately, this book is not intended to explain the multithreading theme and how it works in Ruby. To get...