Thread safety: move the inline function back into a namespace

Moving it into a struct makes things work because it implicitly marks
the function as inline.  The struct is unnecessary if you explicitly
mark the function inline.