fix #3958: make SCOPED_TIMER* threadsafe