Skip to content

Commit 3136e15

Browse files
committed
Merge libdispatch-1324.41.2
Signed-off-by: Rokhini Prabhu <rokhinip@apple.com>
1 parent 1b3d2a5 commit 3136e15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7804
-1318
lines changed

config/config.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
you don't. */
6262
#define HAVE_DECL_VQ_VERYLOWDISK 1
6363

64+
/* Define to 1 if you have the declaration of `VQ_SERVEREVENT', and to 0 if
65+
you don't. */
66+
#define HAVE_DECL_VQ_SERVEREVENT 1
67+
6468
/* Define to 1 if you have the declaration of `VQ_QUOTA', and to 0 if
6569
you don't. */
6670
#define HAVE_DECL_VQ_QUOTA 1
@@ -121,15 +125,27 @@
121125
/* Define if you have the Objective-C runtime */
122126
#define HAVE_OBJC 1
123127

128+
/* Define to 1 if you have the `posix_fadvise' function. */
129+
#define HAVE_POSIX_FADVISE 0
130+
131+
/* Define to 1 if you have the `posix_spawnp' function. */
132+
#define HAVE_POSIX_SPAWNP 1
133+
124134
/* Define to 1 if you have the `pthread_key_init_np' function. */
125135
#define HAVE_PTHREAD_KEY_INIT_NP 1
126136

137+
/* Define to 1 if you have the `pthread_attr_setcpupercent_np' function. */
138+
#define HAVE_PTHREAD_ATTR_SETCPUPERCENT_NP 1
139+
127140
/* Define to 1 if you have the <pthread_machdep.h> header file. */
128141
#define HAVE_PTHREAD_MACHDEP_H 1
129142

130143
/* Define to 1 if you have the `pthread_main_np' function. */
131144
#define HAVE_PTHREAD_MAIN_NP 1
132145

146+
/* Define to 1 if you have the `pthread_yield_np' function. */
147+
#define HAVE_PTHREAD_YIELD_NP 1
148+
133149
/* Define to 1 if you have the <pthread_np.h> header file. */
134150
/* #undef HAVE_PTHREAD_NP_H */
135151

dispatch/dispatch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#endif
6363

6464
#include <os/object.h>
65+
#include <os/workgroup.h>
6566
#include <dispatch/base.h>
6667
#include <dispatch/time.h>
6768
#include <dispatch/object.h>

dispatch/queue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
496496
void
497497
dispatch_apply(size_t iterations,
498498
dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
499-
DISPATCH_NOESCAPE void (^block)(size_t));
499+
DISPATCH_NOESCAPE void (^block)(size_t iteration));
500500
#endif
501501

502502
/*!
@@ -531,7 +531,7 @@ DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_NOTHROW
531531
void
532532
dispatch_apply_f(size_t iterations,
533533
dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
534-
void *_Nullable context, void (*work)(void *_Nullable, size_t));
534+
void *_Nullable context, void (*work)(void *_Nullable context, size_t iteration));
535535

536536
/*!
537537
* @function dispatch_get_current_queue

dispatch/workloop.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,33 @@ void
133133
dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
134134
dispatch_autorelease_frequency_t frequency);
135135

136+
/*!
137+
* @function dispatch_workloop_set_os_workgroup
138+
*
139+
* @abstract
140+
* Associates an os_workgroup_t with the specified dispatch workloop.
141+
*
142+
* The worker thread will be a member of the specified os_workgroup_t while executing
143+
* work items submitted to the workloop.
144+
*
145+
* @param workloop
146+
* The dispatch workloop to modify.
147+
*
148+
* This workloop must be inactive, passing an activated object is undefined
149+
* and will cause the process to be terminated.
150+
*
151+
* @param workgroup
152+
* The workgroup to associate with this workloop.
153+
*
154+
* The workgroup specified is retained and the previously associated workgroup
155+
* (if any) is released.
156+
*/
157+
API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0), watchos(7.0))
158+
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
159+
void
160+
dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop,
161+
os_workgroup_t workgroup);
162+
136163
__END_DECLS
137164

138165
DISPATCH_ASSUME_NONNULL_END

libdispatch.xcodeproj/project.pbxproj

Lines changed: 297 additions & 56 deletions
Large diffs are not rendered by default.

man/dispatch.3

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ concurrent execution via the core functions described in
1313
.Xr dispatch_async 3 and
1414
.Xr dispatch_apply 3 .
1515
.Pp
16-
Dispatch queues are the basic units of organization of blocks. Several queues
17-
are created by default, and applications may create additional queues for their
18-
own use. See
16+
Dispatch queues are the basic units of organization of blocks.
17+
Several queues are created by default, and applications may create additional
18+
queues for their own use.
19+
See
1920
.Xr dispatch_queue_create 3
2021
for more information.
2122
.Pp
2223
Dispatch groups allow applications to track the progress of blocks submitted to
23-
queues and take action when the blocks complete. See
24+
queues and take action when the blocks complete.
25+
See
2426
.Xr dispatch_group_create 3
2527
for more information.
2628
.Pp

man/dispatch_after.3

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ and the time at which the function is called, with the leeway capped to at least
4040
.Pp
4141
For a more detailed description about submitting blocks to queues, see
4242
.Xr dispatch_async 3 .
43+
.Sh FUNDAMENTALS
44+
The
45+
.Fn dispatch_after
46+
function is a wrapper around
47+
.Fn dispatch_after_f .
48+
.Sh SEE ALSO
49+
.Xr dispatch 3 ,
50+
.Xr dispatch_async 3 ,
51+
.Xr dispatch_time 3
4352
.Sh CAVEATS
4453
.Fn dispatch_after
4554
retains the passed queue.
@@ -57,13 +66,3 @@ The result of passing
5766
as the
5867
.Fa when
5968
parameter is undefined.
60-
.Pp
61-
.Sh FUNDAMENTALS
62-
The
63-
.Fn dispatch_after
64-
function is a wrapper around
65-
.Fn dispatch_after_f .
66-
.Sh SEE ALSO
67-
.Xr dispatch 3 ,
68-
.Xr dispatch_async 3 ,
69-
.Xr dispatch_time 3

man/dispatch_api.3

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ consider when designing and implementing API in terms of dispatch queues
1111
and blocks.
1212
.Pp
1313
A general recommendation is to allow both a callback block and target dispatch
14-
queue to be specified. This gives the application the greatest flexibility in
15-
handling asynchronous events.
14+
queue to be specified.
15+
This gives the application the greatest flexibility in handling asynchronous
16+
events.
1617
.Pp
1718
It's also recommended that interfaces take only a single block as the last
18-
parameter. This is both for consistency across projects, as well as the visual
19-
aesthetics of multiline blocks that are declared inline. The dispatch queue to
20-
which the block will be submitted should immediately precede the block argument
21-
(second-to-last argument). For example:
22-
.Pp
19+
parameter.
20+
This is both for consistency across projects, as well as the visual aesthetics
21+
of multiline blocks that are declared inline.
22+
The dispatch queue to which the block will be submitted should immediately
23+
precede the block argument (second-to-last argument).
24+
For example:
2325
.Bd -literal -offset indent
2426
read_async(file, callback_queue, ^{
2527
printf("received callback.\\n");
@@ -34,10 +36,8 @@ pointer, and a new last parameter is added, which is the function to call.
3436
The function based callback should pass the context pointer as the first
3537
argument, and the subsequent arguments should be identical to the block based
3638
variant (albeit offset by one in order).
37-
.Pp
38-
It is also important to use consistent naming. The dispatch API, for example,
39-
uses the suffix "_f" for function based variants.
40-
.Pp
39+
It is also important to use consistent naming.
40+
The dispatch API, for example, uses the suffix "_f" for function based variants.
4141
.Sh SEE ALSO
4242
.Xr dispatch 3 ,
4343
.Xr dispatch_async 3 ,

man/dispatch_apply.3

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ dispatch_apply(iterations, DISPATCH_APPLY_AUTO, ^(size_t idx) {
3030
});
3131
.Ed
3232
.Pp
33-
Although any queue can be used, it is strongly recommended to use
33+
Although any queue can be used, it is strongly recommended to use
3434
.Vt DISPATCH_APPLY_AUTO
35-
as the
36-
.Vt queue
35+
as the
36+
.Vt queue
3737
argument to both
3838
.Fn dispatch_apply
3939
and
40-
.Fn dispatch_apply_f ,
40+
.Fn dispatch_apply_f ,
4141
as shown in the example above, since this allows the system to automatically use worker threads
4242
that match the configuration of the current thread as closely as possible.
4343
No assumptions should be made about which global concurrent queue will be used.
@@ -75,7 +75,8 @@ for (i = count - (count % STRIDE); i < count; i++) {
7575
.Ed
7676
.Sh IMPLIED REFERENCES
7777
Synchronous functions within the dispatch framework hold an implied reference
78-
on the target queue. In other words, the synchronous function borrows the
78+
on the target queue.
79+
In other words, the synchronous function borrows the
7980
reference of the calling function (this is valid because the calling function
8081
is blocked waiting for the result of the synchronous function, and therefore
8182
cannot modify the reference count of the target queue until after the
@@ -95,7 +96,7 @@ or
9596
.Fn dispatch_async_f
9697
will incur more overhead and does not express the desired parallel execution semantics to
9798
the system, so may not create an optimal number of worker threads for a parallel workload.
98-
For this reason, prefer to use
99+
For this reason, prefer to use
99100
.Fn dispatch_apply
100101
or
101102
.Fn dispatch_apply_f
@@ -105,18 +106,18 @@ The
105106
.Fn dispatch_apply
106107
function is a wrapper around
107108
.Fn dispatch_apply_f .
109+
.Sh SEE ALSO
110+
.Xr dispatch 3 ,
111+
.Xr dispatch_async 3 ,
112+
.Xr dispatch_queue_create 3
108113
.Sh CAVEATS
109114
Unlike
110115
.Fn dispatch_async ,
111116
a block submitted to
112117
.Fn dispatch_apply
113118
is expected to be either independent or dependent
114119
.Em only
115-
on work already performed in lower-indexed invocations of the block. If
116-
the block's index dependency is non-linear, it is recommended to
117-
use a for-loop around invocations of
120+
on work already performed in lower-indexed invocations of the block.
121+
If the block's index dependency is non-linear, it is recommended to use a
122+
for-loop around invocations of
118123
.Fn dispatch_async .
119-
.Sh SEE ALSO
120-
.Xr dispatch 3 ,
121-
.Xr dispatch_async 3 ,
122-
.Xr dispatch_queue_create 3

0 commit comments

Comments
 (0)