Fix race condition when setting callbacks

Prevents a race condition that may occur if the future returns
while a callback is being set.
Merge pull request #95 from JeremyOT/race

Fix race condition when setting callbacks