You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
benchmarks
cmake
docs
DesignDocs
ABIVersioning.rst
AvailabilityMarkup.rst
CapturingConfigInfo.rst
DebugMode.rst
ThreadingSupportAPI.rst
VisibilityMacros.rst
BuildingLibcxx.rst
CMakeLists.txt
Makefile.sphinx
README.txt
TestingLibcxx.rst
UsingLibcxx.rst
conf.py
index.rst
fuzzing
include
lib
src
utils
www
.arcconfig
.clang-format
.gitignore
CMakeLists.txt
CREDITS.TXT
LICENSE.TXT
NOTES.TXT
TODO.TXT
appveyor-reqs-install.cmd
appveyor.yml
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
80 lines
3.4 KiB
ReStructuredText
80 lines
3.4 KiB
ReStructuredText
![]() |
=====================
|
||
|
Threading Support API
|
||
|
=====================
|
||
|
|
||
|
.. contents::
|
||
|
:local:
|
||
|
|
||
|
Overview
|
||
|
========
|
||
|
|
||
|
Libc++ supports using multiple different threading models and configurations
|
||
|
to implement the threading parts of libc++, including ``<thread>`` and ``<mutex>``.
|
||
|
These different models provide entirely different interfaces from each
|
||
|
other. To address this libc++ wraps the underlying threading API in a new and
|
||
|
consistent API, which it uses internally to implement threading primitives.
|
||
|
|
||
|
The ``<__threading_support>`` header is where libc++ defines its internal
|
||
|
threading interface. It contains forward declarations of the internal threading
|
||
|
interface as well as definitions for the interface.
|
||
|
|
||
|
External Threading API and the ``<__external_threading>`` header
|
||
|
================================================================
|
||
|
|
||
|
In order to support vendors with custom threading API's libc++ allows the
|
||
|
entire internal threading interface to be provided by an external,
|
||
|
vendor provided, header.
|
||
|
|
||
|
When ``_LIBCPP_HAS_THREAD_API_EXTERNAL`` is defined the ``<__threading_support>``
|
||
|
header simply forwards to the ``<__external_threading>`` header (which must exist).
|
||
|
It is expected that the ``<__external_threading>`` header provide the exact
|
||
|
interface normally provided by ``<__threading_support>``.
|
||
|
|
||
|
External Threading Library
|
||
|
==========================
|
||
|
|
||
|
libc++ can be compiled with its internal threading API delegating to an external
|
||
|
library. Such a configuration is useful for library vendors who wish to
|
||
|
distribute a thread-agnostic libc++ library, where the users of the library are
|
||
|
expected to provide the implementation of the libc++ internal threading API.
|
||
|
|
||
|
On a production setting, this would be achieved through a custom
|
||
|
``<__external_threading>`` header, which declares the libc++ internal threading
|
||
|
API but leaves out the implementation.
|
||
|
|
||
|
The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
|
||
|
such a configuration while allowing it to be tested on a platform that supports
|
||
|
any of the threading systems (e.g. pthread) supported in ``__threading_support``
|
||
|
header. Therefore, the main purpose of this option is to allow testing of this
|
||
|
particular configuration of the library without being tied to a vendor-specific
|
||
|
threading system. This option is only meant to be used by libc++ library
|
||
|
developers.
|
||
|
|
||
|
Threading Configuration Macros
|
||
|
==============================
|
||
|
|
||
|
**_LIBCPP_HAS_NO_THREADS**
|
||
|
This macro is defined when libc++ is built without threading support. It
|
||
|
should not be manually defined by the user.
|
||
|
|
||
|
**_LIBCPP_HAS_THREAD_API_EXTERNAL**
|
||
|
This macro is defined when libc++ should use the ``<__external_threading>``
|
||
|
header to provide the internal threading API. This macro overrides
|
||
|
``_LIBCPP_HAS_THREAD_API_PTHREAD``.
|
||
|
|
||
|
**_LIBCPP_HAS_THREAD_API_PTHREAD**
|
||
|
This macro is defined when libc++ should use POSIX threads to implement the
|
||
|
internal threading API.
|
||
|
|
||
|
**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
|
||
|
This macro is defined when libc++ expects the definitions of the internal
|
||
|
threading API to be provided by an external library. When defined
|
||
|
``<__threading_support>`` will only provide the forward declarations and
|
||
|
typedefs for the internal threading API.
|
||
|
|
||
|
**_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL**
|
||
|
This macro is used to build an external threading library using the
|
||
|
``<__threading_support>``. Specifically it exposes the threading API
|
||
|
definitions in ``<__threading_support>`` as non-inline definitions meant to
|
||
|
be compiled into a library.
|