Skip to content

Commit 11e903d

Browse files
Merge pull request MicrosoftDocs#5100 from MicrosoftDocs/main638618455462341592sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents f724446 + 267ce76 commit 11e903d

File tree

3 files changed

+51
-39
lines changed

3 files changed

+51
-39
lines changed

docs/standard-library/execution.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: <execution>"
33
title: "<execution>"
4-
ms.date: "08/17/2021"
4+
ms.date: 09/11/2024
55
f1_keywords: ["<execution>", "execution/std::execution", "std::execution"]
66
helpviewer_keywords: ["execution header"]
77
---
@@ -22,24 +22,30 @@ namespace std::execution {
2222
}
2323
```
2424
25-
### Classes and Structs
25+
### Classes and structs
2626
2727
|Name|Description|
2828
|-|-|
2929
|[`is_execution_policy` Struct](is-execution-policy-struct.md)|Detects execution policies to exclude certain function signatures from otherwise ambiguous overload resolution participation.|
30-
|[`parallel_policy` Class](parallel-policy-class.md)|Used as a unique type to disambiguate parallel algorithm overloading. Indicates that a parallel algorithm's execution may be parallelized.|
31-
|[`parallel_unsequenced_policy` Class](parallel-unsequenced-policy-class.md)|Used as a unique type to disambiguate parallel algorithm overloading. Indicates that a parallel algorithm's execution may be parallelized and vectorized.|
32-
|[`sequenced_policy` Class](sequenced-policy-class.md)|Used as a unique type to disambiguate parallel algorithm overloading. Specifies that a parallel algorithm's execution may not be parallelized.|
30+
|[`parallel_policy` class](parallel-policy-class.md)|Used to disambiguate parallel algorithm overloading. Indicates that a parallel algorithm's execution may be parallelized.|
31+
|[`parallel_unsequenced_policy` class](parallel-unsequenced-policy-class.md)|Used as a unique type to disambiguate parallel algorithm overloading. Indicates that a parallel algorithm's execution may be parallelized and vectorized.|
32+
|[`sequenced_policy` class](sequenced-policy-class.md)|Used as a unique type to disambiguate parallel algorithm overloading. Specifies that a parallel algorithm's execution may not be parallelized.|
3333
34-
### Microsoft Specific
35-
36-
When `parallel_policy` or `parallel_unsequenced_policy` cause the algorithm to be parallelized, the parallel execution uses Windows Thread Pool; see [Thread Pools](/windows/win32/procthread/thread-pools). The number of concurrent threads is limited to the thread pool default (currently 500). The number of threads concurrently executing on hardware is currently limited by the number of logical processors in the current process's processor group, so it is effectively limited to 64; see [Processor Groups](/windows/win32/procthread/processor-groups). The maximum number of chunks for data partitioning is also currently based on the number of logical processors in the current process's processor group.
34+
### Microsoft specific
35+
36+
Parallel algorithms execute on an unspecified number of threads and divide the work into an unspecified number of data partitioning "chunks." The Windows thread pool manages the number of threads. The implementation tries to make use of the available logical processors, which corresponds to the number of hardware threads that can execute simultaneously.
37+
38+
Specifying `parallel_policy` or `parallel_unsequenced_policy` causes standard library algorithms to run in parallel using the Windows Thread Pool. The number of concurrent threads, and thus the number of "chunks" for data partitioning, is limited to 500 threads because that's the default number of thread pool threads. For more information, see [Thread Pools](/windows/win32/procthread/thread-pools).
39+
40+
Before Windows 11 and Windows Server 2022, applications were limited by default to a single processor group having at most 64 logical processors. This limited the number of concurrently executing threads to 64. For more information, see [Processor Groups](/windows/win32/procthread/processor-groups).
41+
42+
Starting with Windows 11 and Windows Server 2022, processes and their threads have processor affinities that by default span all processors in the system and across multiple groups on machines with more than 64 processors. The limit on the number of concurrent threads is now the total number of logical processors in the system.
3743
3844
## Requirements
3945
40-
**Header:** \<execution>
46+
**Header:** `<execution>`
4147
42-
**Namespace:** std
48+
**Namespace:** `std`
4349
4450
## See also
4551

docs/standard-library/future-functions.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: <future> functions"
33
title: "<future> functions"
4-
ms.date: "08/17/2021"
4+
ms.date: 09/11/2024
55
f1_keywords: ["future/std::async", "future/std::future_category", "future/std::make_error_code", "future/std::make_error_condition", "future/std::swap"]
66
helpviewer_keywords: ["std::async [C++]", "std::future_category [C++]", "std::make_error_code [C++]", "std::make_error_condition [C++]", "std::swap [C++]"]
77
---
@@ -29,7 +29,7 @@ future<typename result_of<Fn(ArgTypes...)>::type>
2929
3030
### Parameters
3131
32-
*policy*\
32+
*`policy`*\
3333
A [`launch`](../standard-library/future-enums.md#launch) value.
3434
3535
### Remarks
@@ -48,24 +48,28 @@ The second function returns a `future<Ty>` object whose *associated asynchronous
4848
4949
Unless `decay<Fn>::type` is a type other than launch, the second function doesn't participate in overload resolution.
5050
51-
The C++ standard states that if the policy is `launch::async`, the function behaves as if it invokes the callable object in a new thread. This means that while it typically results in creating a new thread, the implementation may use other mechanisms to achieve equivalent behavior. However, the Microsoft implementation currently does not conform strictly to this behavior. It obtains its threads from the Windows ThreadPool, which may provide a recycled thread rather than a new one. This means that the `launch::async` policy is effectively implemented as `launch::async|launch::deferred`. Another implication of the ThreadPool-based implementation is that there's no guarantee that thread-local variables will be destroyed when the thread completes. If the thread is recycled and provided to a new call to `async`, the old variables will still exist. We recommend that you avoid using thread-local variables with `async`.
51+
The C++ standard states that if the policy is `launch::async`, the function behaves as if it invokes the callable object in a new thread. This means that while it typically results in creating a new thread, the implementation may use other mechanisms to achieve equivalent behavior. However, the Microsoft implementation currently doesn't conform strictly to this behavior. It obtains threads from the Windows ThreadPool, which may provide a recycled thread rather than a new one. This means that the `launch::async` policy is effectively implemented as `launch::async|launch::deferred`. Another implication of the ThreadPool-based implementation is that there's no guarantee that thread-local variables are destroyed when the thread completes. If the thread is recycled and provided to a new call to `async`, the old variables still exist. We recommend that you avoid using thread-local variables with `async`.
5252
53-
If *policy* is `launch::deferred`, the function marks its associated asynchronous state as holding a *deferred function* and returns. The first call to any non-timed function that waits for the associated asynchronous state to be ready in effect calls the deferred function by evaluating `INVOKE(dfn, dargs..., Ty)`.
53+
If *`policy`* is `launch::deferred`, the function marks its associated asynchronous state as holding a *deferred function* and returns. The first call to any nontimed function that waits for the associated asynchronous state to be ready in effect calls the deferred function by evaluating `INVOKE(dfn, dargs..., Ty)`.
5454
55-
In all cases, the associated asynchronous state of the `future` object isn't set to *ready* until the evaluation of `INVOKE(dfn, dargs..., Ty)` completes, either by throwing an exception or by returning normally. The result of the associated asynchronous state is an exception if one was thrown, or any value that's returned by the evaluation.
55+
In all cases, the associated asynchronous state of the `future` object isn't set to *ready* until the evaluation of `INVOKE(dfn, dargs..., Ty)` completes, either by throwing an exception or by returning normally. The result of the associated asynchronous state is an exception if one was thrown, or the value the evaluation returns.
5656
5757
> [!NOTE]
5858
> For a `future`—or the last [`shared_future`](../standard-library/shared-future-class.md)—that's attached to a task started with `std::async`, the destructor blocks if the task has not completed; that is, it blocks if this thread did not yet call `.get()` or `.wait()` and the task is still running. If a `future` obtained from `std::async` is moved outside the local scope, other code that uses it must be aware that its destructor may block for the shared state to become ready.
5959
6060
The pseudo-function `INVOKE` is defined in [`<functional>`](../standard-library/functional.md).
6161
62-
### Microsoft Specific
62+
**Microsoft specific**
6363
64-
When the passed function is executed asynchronously, it's executed on Windows Thread Pool; see [Thread Pools](/windows/win32/procthread/thread-pools). The number of concurrent threads is limited to the thread pool default (currently 500). The number of threads concurrently executing on hardware is currently limited by the number of logical processor in the process's processor group, so it's effectively limited to 64; see [Processor Groups](/windows/win32/procthread/processor-groups).
64+
When the passed function is executed asynchronously, it executes on the Windows Thread Pool. For more information, see [Thread Pools](/windows/win32/procthread/thread-pools). The number of concurrent threads is limited to the thread pool default, which is 500 threads.
65+
66+
Before Windows 11 and Windows Server 2022, applications were limited by default to a single processor group having at most 64 logical processors. This limited the number of concurrently executing threads to 64. For more information, see [Processor Groups](/windows/win32/procthread/processor-groups).
67+
68+
Starting with Windows 11 and Windows Server 2022, processes and their threads have processor affinities that by default span all processors in the system and across multiple groups on machines with more than 64 processors. The limit on the number of concurrent threads is now the total number of logical processors in the system.
6569
6670
## <a name="future_category"></a> `future_category`
6771
68-
Returns a reference to the [error_category](../standard-library/error-category-class.md) object that characterizes errors that are associated with `future` objects.
72+
Returns a reference to the [`error_category`](../standard-library/error-category-class.md) object that characterizes errors that are associated with `future` objects.
6973
7074
```cpp
7175
const error_category& future_category() noexcept;
@@ -82,15 +86,15 @@ inline error_code make_error_code(future_errc Errno) noexcept;
8286
### Parameters
8387
8488
*`Errno`*\
85-
A [future_errc](../standard-library/future-enums.md#future_errc) value that identifies the reported error.
89+
A [`future_errc`](../standard-library/future-enums.md#future_errc) value that identifies the reported error.
8690
8791
### Return Value
8892
8993
`error_code(static_cast<int>(Errno), future_category());`
9094
9195
## <a name="make_error_condition"></a> `make_error_condition`
9296
93-
Creates an [error_condition](../standard-library/error-condition-class.md) together with the [error_category](../standard-library/error-category-class.md) object that characterizes [future](../standard-library/future-class.md) errors.
97+
Creates an [`error_condition`](../standard-library/error-condition-class.md) together with the [`error_category`](../standard-library/error-category-class.md) object that characterizes [`future`](../standard-library/future-class.md) errors.
9498
9599
```cpp
96100
inline error_condition make_error_condition(future_errc Errno) noexcept;
@@ -99,7 +103,7 @@ inline error_condition make_error_condition(future_errc Errno) noexcept;
99103
### Parameters
100104

101105
*`Errno`*\
102-
A [future_errc](../standard-library/future-enums.md#future_errc) value that identifies the reported error.
106+
A [`future_errc`](../standard-library/future-enums.md#future_errc) value that identifies the reported error.
103107

104108
### Return Value
105109

docs/standard-library/thread-class.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: thread Class"
33
title: "thread Class"
4-
ms.date: 06/20/2022
4+
ms.date: 09/11/2024
55
f1_keywords: ["thread/std::thread", "thread/std::thread::id Class", "thread/std::thread::thread", "thread/std::thread::detach", "thread/std::thread::get_id", "thread/std::thread::hardware_concurrency", "thread/std::thread::join", "thread/std::thread::joinable", "thread/std::thread::native_handle", "thread/std::thread::swap"]
66
helpviewer_keywords: ["std::thread [C++]", "std::thread [C++], thread", "std::thread [C++], detach", "std::thread [C++], get_id", "std::thread [C++], hardware_concurrency", "std::thread [C++], join", "std::thread [C++], joinable", "std::thread [C++], native_handle", "std::thread [C++], swap"]
77
ms.custom: devdivchpfy22
@@ -73,9 +73,9 @@ void detach();
7373

7474
After a call to `detach`, subsequent calls to [`get_id`](#get_id) return [`id`](#id_class).
7575

76-
If the thread that's associated with the calling object isn't joinable, the function throws a [`system_error`](../standard-library/system-error-class.md) that has an error code of `invalid_argument`.
76+
If the thread associated with the calling object isn't joinable, the function throws a [`system_error`](../standard-library/system-error-class.md) that has an error code of `invalid_argument`.
7777

78-
If the thread that's associated with the calling object is invalid, the function throws a `system_error` that has an error code of `no_such_process`.
78+
If the thread associated with the calling object is invalid, the function throws a `system_error` that has an error code of `no_such_process`.
7979

8080
## <a name="get_id"></a> `get_id`
8181

@@ -85,9 +85,9 @@ Returns a unique identifier for the associated thread.
8585
id get_id() const noexcept;
8686
```
8787

88-
### Return Value
88+
### Return value
8989

90-
A [`id`](#id_class) object that uniquely identifies the associated thread, or `id()` if no thread is associated with the object.
90+
An [`id`](#id_class) object that uniquely identifies the associated thread, or `id()` if no thread is associated with the object.
9191

9292
## <a name="hardware_concurrency"></a> `hardware_concurrency`
9393

@@ -97,15 +97,17 @@ Static method that returns an estimate of the number of hardware thread contexts
9797
static unsigned int hardware_concurrency() noexcept;
9898
```
9999

100-
### Return Value
100+
### Return value
101101

102102
An estimate of the number of hardware thread contexts. If the value can't be computed or isn't well defined, this method returns 0.
103103

104-
### Microsoft Specific
104+
**Microsoft specific**
105105

106-
`hardware_concurrency` is currently defined to return the number of logical processors, which corresponds to the number of hardware threads that can execute simultaneously. It takes into account the number of physical processors, the number of cores in each physical processor, and simultaneous multithreading on each single core.
107-
108-
However, on systems with more than 64 logical processors this number is capped by the number of logical processors in a single group; see [Processor Groups](/windows/win32/procthread/processor-groups).
106+
`hardware_concurrency` returns the number of logical processors, which corresponds to the number of hardware threads that can execute simultaneously. It takes into account the number of physical processors, the number of cores in each physical processor, and simultaneous multithreading on each single core.
107+
108+
Before Windows 11 and Windows Server 2022, applications were limited by default to a single processor group, having at most 64 logical processors. This limited the number of concurrently executing threads to 64. For more information, see [Processor Groups](/windows/win32/procthread/processor-groups).
109+
110+
Starting with Windows 11 and Windows Server 2022, processes and their threads have processor affinities that by default span all processors in the system and across multiple groups on machines with more than 64 processors. The limit on the number of concurrent threads is now the total number of logical processors in the system.
109111

110112
## <a name="id_class"></a> `id` class
111113

@@ -125,7 +127,7 @@ All default-constructed `thread::id` objects compare equal.
125127
126128
## <a name="join"></a> `join`
127129
128-
Blocks until the thread of execution that's associated with the calling object completes.
130+
Blocks until the thread of execution associated with the calling object completes.
129131
130132
```cpp
131133
void join();
@@ -143,7 +145,7 @@ Specifies whether the associated thread is joinable.
143145
bool joinable() const noexcept;
144146
```
145147

146-
### Return Value
148+
### Return value
147149

148150
**`true`** if the associated thread is joinable; otherwise, **`false`**.
149151

@@ -159,9 +161,9 @@ Returns the implementation-specific type that represents the thread handle. The
159161
native_handle_type native_handle();
160162
```
161163

162-
### Return Value
164+
### Return value
163165

164-
`native_handle_type` is defined as a Win32 `HANDLE` that's cast as `void *`.
166+
`native_handle_type` is defined as a Win32 `HANDLE` cast as `void *`.
165167

166168
## <a name="op_eq"></a> `thread::operator=`
167169

@@ -176,7 +178,7 @@ thread& operator=(thread&& Other) noexcept;
176178
*`Other`*\
177179
A `thread` object.
178180

179-
### Return Value
181+
### Return value
180182

181183
`*this`
182184

@@ -214,7 +216,7 @@ thread(thread&& Other) noexcept;
214216
### Parameters
215217

216218
*`F`*\
217-
An application-defined function to be executed by the thread.
219+
An application-defined function to execute on the thread.
218220

219221
*`A`*\
220222
A list of arguments to be passed to *`F`*.
@@ -224,9 +226,9 @@ An existing `thread` object.
224226

225227
### Remarks
226228

227-
The first constructor constructs an object that's not associated with a thread of execution. The value that's returned by a call to `get_id` for the constructed object is `thread::id()`.
229+
The first constructor constructs an object that's not associated with a thread of execution. The value returned by `get_id` for the constructed object is `thread::id()`.
228230

229-
The second constructor constructs an object that's associated with a new thread of execution and executes the pseudo-function `INVOKE` that's defined in [`<functional>`](../standard-library/functional.md). If not enough resources are available to start a new thread, the function throws a [`system_error`](../standard-library/system-error-class.md) object that has an error code of `resource_unavailable_try_again`. If the call to *`F`* terminates with an uncaught exception, [`terminate`](../standard-library/exception-functions.md#terminate) is called.
231+
The second constructor constructs an object that's associated with a new thread of execution. It executes the pseudo-function `INVOKE` defined in [`<functional>`](../standard-library/functional.md). If not enough resources are available to start a new thread, the function throws a [`system_error`](../standard-library/system-error-class.md) object that has an error code of `resource_unavailable_try_again`. If the call to *`F`* terminates with an uncaught exception, [`terminate`](../standard-library/exception-functions.md#terminate) is called.
230232

231233
The third constructor constructs an object that's associated with the thread that's associated with `Other`. `Other` is then set to a default-constructed state.
232234

0 commit comments

Comments
 (0)