Optimization in Development Tools
- Move the unloading/cleanup completely into a background-thread
- Do the cleanup in 2 phases. One "soft" phase, where no write-lock is held over the whole time.
This prevents the UI from blocking, the only problem is that it doesn't guarantee disk consistency.
Thus, after this phase, do the same again, this time with a complete write-lock.
We stop all parsing threads before the first phase, so the changes that happen are minimal.
Thus we only have to write very few data in the second phase, hold the write-lock for a very short time, thereby preventing the UI from blocking while waiting for a read-lock.
This fixes the annoying and very long UI lockups that happen time by time when a lot of parsing is going on, like parsing a whole project.