mus*_*ero 28 c++ multithreading boost
可以在所谓的线程感知模式下编译BOOST库.如果是这样,您将看到库名称中出现"...- mt ...".我无法理解它给了我什么,我什么时候需要使用这种模式?它能给我带来什么好处吗?
不仅仅是因为在NO-thread-aware体系中编译了BOOST Threads库(名称中没有-mt),我真的很困惑.这对我没有任何意义.看起来自相矛盾:/
非常感谢您的帮助!
Vla*_*rus 20
因为你没有具体说明你的构建方式,在什么平台上,我将解释整个故事.在Linux和Windows上,Boost.Thread库都是在MT模式下构建的.在Windows上,默认情况下,为它获取-mt后缀.在Linux上,默认情况下为1.42,没有后缀.你在Linux上没有后缀的原因是几乎没有其他的库使用这样的约定,而且它在Linux上的重要性要低得多.
这澄清了什么吗?
And*_*nov 16
可以选择将"-mt"后缀放回(bjam --layout=tagged)
--layout=<layout> Determines whether to choose library names
and header locations such that multiple
versions of Boost or multiple compilers can
be used on the same system.
versioned - Names of boost binaries
include the Boost version number, name and
version of the compiler and encoded build
properties. Boost headers are installed in a
subdirectory of <HDRDIR> whose name contains
the Boost version number.
tagged -- Names of boost binaries include the
encoded build properties such as variant and
threading, but do not including compiler name
and version, or Boost version. This option is
useful if you build several variants of Boost,
using the same compiler.
system - Binaries names do not include the
Boost version number or the name and version
number of the compiler. Boost headers are
installed directly into <HDRDIR>. This option
is intended for system integrators who are
building distribution packages.
The default value is 'versioned' on Windows, and
'system' on Unix.
Run Code Online (Sandbox Code Playgroud)
我不是 Boost 专家,但我认为是这样的:
在 MT 环境中,任何全局或共享数据都可能有多个线程尝试同时访问它,这可能会导致数据损坏。MT 感知对象将使用同步(关键部分、互斥体等)来确保一次只有一个线程可以访问数据。
Boost 线程库中的某些函数可能仍然可以在单线程程序中工作。或者,这些函数可以解析为无操作(无害的不执行任何操作的函数),以便可以使用 MT(并且 boost 函数起作用)或单线程(并且 boost 函数不执行任何操作)来编译相同的程序,而无需更改代码。
| 归档时间: |
|
| 查看次数: |
16498 次 |
| 最近记录: |