make thread_guard and thread_safe work with var and function decls