magicalpanda/MagicalRecord — pull request #472 by chrisgibbs (2013-05-07 21:49:43+00:00)
Title: Cleanup when finished

This adds functionality to track the count of ongoing performBlock and save operations. This count allows for the ability to perform clean up when the current operations count reaches zero.

This provides a solution for the scenario in which long-running tasks are executing inside of the block being performed on a MOC and we want MagicalRecord to perform a clean up (For example in an application lockdown). Now a cleanUpWhenFinishedSaving method can be called to only tear down the Core Data stack when any ongoing operations have finished.

It is still the application's responsibility to prevent any future operations from being sent to MagicalRecord. However if cleanUpWhenFinishedSaving has been called, cleanUp will be executed when all performBlock and save operations have finished.

*Note* Created pull request against develop branch in response to https://github.com/magicalpanda/MagicalRecord/pull/471