c++ - Are member functions of std::wstring_convert thread safe? -


we're using a

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; 

in logger of ours gets utf-16 string legacy component , converts utf-8 write log. converter gets instantiated on each conversion, upon do

auto utf8string = converter.to_bytes(utf16string); 

this done in pretty intensive , multi-threaded part of our code , i'd re-use 1 instance of converter, seing std::wstring_convert exposes "state", i'm worried to_bytes not thread safe , gains reusing same instance lost excessive locking needed (in case wouldn't share instance anyway).

so, std::wstring_convert<>::to_bytes thread safe?

edit: clarification on i'm asking: given 1 instance of std::wstring_convert<>, if 2 or more threads concurrently call to_bytes on instance different arguments, to_bytes guaranteed behave well?

because std::wstring_convert part of standard library, follows certain rules when comes handling object of such type different threads.

in particular, because both to_bytes , from_bytes overloads non-const, not possible use members on 1 particular object different threads without synchronization. makes sense, codecvt conversions typically make use of state_type object. using without synchronization lead disaster.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -