Avoid calling callbacks while holding locks

Instead of calling the callback while holding
a write lock (a recipe for deadlock) call the
callbacks after we pop all the values to avoid
any potential for deadlock.

Change-Id: Idb4275d8f07d60e2ed83c0987b6c7354a09c8a71
Merge "Avoid calling callbacks while holding locks"