add SafeAsyncQueue class
fix compiler warnings in tools.cpp