C++ implementation of throttling mechanism