CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
68 lines
2.6 KiB
ReStructuredText
68 lines
2.6 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 ``<__thread/support.h>`` header is where libc++ defines its internal
|
|
threading interface. It documents the functions and declarations required
|
|
to fullfil the internal threading 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 ``<__thread/support.h>``
|
|
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 ``<__thread/support.h>``.
|
|
|
|
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.
|
|
|
|
Threading Configuration Macros
|
|
==============================
|
|
|
|
**_LIBCPP_HAS_THREADS**
|
|
This macro is set to 1 when libc++ is built with threading support. Otherwise
|
|
it is set to 0. 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_API_C11**
|
|
This macro is defined when libc++ should use C11 threads to implement the
|
|
internal threading API.
|
|
|
|
**_LIBCPP_HAS_THREAD_API_WIN32**
|
|
This macro is defined when libc++ should use Win32 threads to implement the
|
|
internal threading API.
|