BOOST libraries in multithreading-aware mode

前端 未结 6 2064
野的像风
野的像风 2020-12-03 02:44

There is a possibility to compile BOOST libraries in the so-called thread-aware mode. If so you will see \"...-mt...\" appeared in the library name. I can\'t understand wha

6条回答
  •  無奈伤痛
    2020-12-03 03:24

    I'm not a Boost guru, but I assume it is this:

    In a MT environment, any global or shared data may have more than one thread trying to access it at the same time, which can lead to data corruption. An MT-aware object will use synchronisation (Critical Sections, Mutexes, etc.) to ensure that only one thread can access data at a time.

    There might be functions in the Boost thread library that still work in single-threaded programs. Alternatively, the functions may resolve to no-ops (harmless do-nothing functions) so that the same program can be compiled with MT (and the boost functions work) or Single threaded (and the boost functions do nothing) without having to change the code.

提交回复
热议问题