
3 Jun
2009
3 Jun
'09
1:57 p.m.
Ovanes Markarian ha scritto:
void io_worker_thread(void) { #if (WIN32) CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); #endif
io_service.run();
#if (WIN32) CoUninitialize(); #endif };
It is better to use at least RAII here. This approach is not exception safe and if io_service.run() throws an exception CoUnintialize() will not be called.
You're right! But how can I adapt this code to use RAII? Maybe is more simple to add a try-catch statement? Daniele.