From Jason Turner

[futures.task]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpiqlttxy2/{from.md → to.md} +36 -220
tmp/tmpiqlttxy2/{from.md → to.md} RENAMED
@@ -20,10 +20,12 @@ namespace std {
20
  public:
21
  // construction and destruction
22
  packaged_task() noexcept;
23
  template<class F>
24
  explicit packaged_task(F&& f);
 
 
25
  ~packaged_task();
26
 
27
  // no copy
28
  packaged_task(const packaged_task&) = delete;
29
  packaged_task& operator=(const packaged_task&) = delete;
@@ -63,24 +65,37 @@ packaged_task() noexcept;
63
  ``` cpp
64
  template<class F>
65
  explicit packaged_task(F&& f);
66
  ```
67
 
 
 
 
 
 
 
 
 
68
  *Constraints:* `remove_cvref_t<F>` is not the same type as
69
  `packaged_task<R(ArgTypes...)>`.
70
 
71
- *Mandates:* `is_invocable_r_v<R, F&, ArgTypes...>` is `true`.
72
 
73
- *Preconditions:* Invoking a copy of `f` behaves the same as invoking
74
- `f`.
75
 
76
- *Effects:* Constructs a new `packaged_task` object with a shared state
77
- and initializes the object’s stored task with `std::forward<F>(f)`.
 
 
 
 
 
78
 
79
- *Throws:* Any exceptions thrown by the copy or move constructor of `f`,
80
- or `bad_alloc` if memory for the internal data structures cannot be
81
- allocated.
82
 
83
  ``` cpp
84
  template<class F> packaged_task(F) -> packaged_task<see below>;
85
  ```
86
 
@@ -190,11 +205,11 @@ where `f` is the stored task and `t`₁`, t`₂`, `…`, t`$_N$ are the values
190
  in `args...`. If the task returns normally, the return value is stored
191
  as the asynchronous result in the shared state of `*this`, otherwise the
192
  exception thrown by the task is stored. In either case, this is done
193
  without making that state ready [[futures.state]] immediately. Schedules
194
  the shared state to be made ready when the current thread exits, after
195
- all objects of thread storage duration associated with the current
196
  thread have been destroyed.
197
 
198
  *Throws:* `future_error` if an error condition occurs.
199
 
200
  *Error conditions:*
@@ -205,21 +220,28 @@ thread have been destroyed.
205
 
206
  ``` cpp
207
  void reset();
208
  ```
209
 
210
- *Effects:* As if `*this = packaged_task(std::move(f))`, where `f` is the
211
- task stored in `*this`.
 
 
 
 
 
 
 
 
 
212
 
213
  [*Note 2*: This constructs a new shared state for `*this`. The old
214
  state is abandoned [[futures.state]]. — *end note*]
215
 
216
  *Throws:*
217
 
218
- - `bad_alloc` if memory for the new shared state cannot be allocated.
219
- - Any exception thrown by the move constructor of the task stored in the
220
- shared state.
221
  - `future_error` with an error condition of `no_state` if `*this` has no
222
  shared state.
223
 
224
  #### Globals <a id="futures.task.nonmembers">[[futures.task.nonmembers]]</a>
225
 
@@ -228,211 +250,5 @@ template<class R, class... ArgTypes>
228
  void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
229
  ```
230
 
231
  *Effects:* As if by `x.swap(y)`.
232
 
233
- <!-- Link reference definitions -->
234
- [alg.sorting]: algorithms.md#alg.sorting
235
- [allocator.requirements.general]: library.md#allocator.requirements.general
236
- [atomic.types.int.comp]: #atomic.types.int.comp
237
- [atomic.types.pointer.comp]: #atomic.types.pointer.comp
238
- [atomics]: #atomics
239
- [atomics.alias]: #atomics.alias
240
- [atomics.fences]: #atomics.fences
241
- [atomics.flag]: #atomics.flag
242
- [atomics.general]: #atomics.general
243
- [atomics.lockfree]: #atomics.lockfree
244
- [atomics.nonmembers]: #atomics.nonmembers
245
- [atomics.order]: #atomics.order
246
- [atomics.ref.float]: #atomics.ref.float
247
- [atomics.ref.generic]: #atomics.ref.generic
248
- [atomics.ref.generic.general]: #atomics.ref.generic.general
249
- [atomics.ref.int]: #atomics.ref.int
250
- [atomics.ref.memop]: #atomics.ref.memop
251
- [atomics.ref.ops]: #atomics.ref.ops
252
- [atomics.ref.pointer]: #atomics.ref.pointer
253
- [atomics.syn]: #atomics.syn
254
- [atomics.types.float]: #atomics.types.float
255
- [atomics.types.generic]: #atomics.types.generic
256
- [atomics.types.generic.general]: #atomics.types.generic.general
257
- [atomics.types.int]: #atomics.types.int
258
- [atomics.types.memop]: #atomics.types.memop
259
- [atomics.types.operations]: #atomics.types.operations
260
- [atomics.types.pointer]: #atomics.types.pointer
261
- [atomics.wait]: #atomics.wait
262
- [barrier.syn]: #barrier.syn
263
- [basic.align]: basic.md#basic.align
264
- [basic.fundamental]: basic.md#basic.fundamental
265
- [basic.life]: basic.md#basic.life
266
- [basic.stc.thread]: basic.md#basic.stc.thread
267
- [bitmask.types]: library.md#bitmask.types
268
- [cfenv]: numerics.md#cfenv
269
- [class.prop]: class.md#class.prop
270
- [compliance]: library.md#compliance
271
- [concept.booleantestable]: concepts.md#concept.booleantestable
272
- [condition.variable.syn]: #condition.variable.syn
273
- [conv.rval]: expr.md#conv.rval
274
- [cpp17.defaultconstructible]: #cpp17.defaultconstructible
275
- [cpp17.destructible]: #cpp17.destructible
276
- [cpp17.moveassignable]: #cpp17.moveassignable
277
- [cpp17.moveconstructible]: #cpp17.moveconstructible
278
- [defns.block]: intro.md#defns.block
279
- [except.terminate]: except.md#except.terminate
280
- [expr.pre]: expr.md#expr.pre
281
- [format.string.std]: utilities.md#format.string.std
282
- [func.invoke]: utilities.md#func.invoke
283
- [func.require]: utilities.md#func.require
284
- [function.objects]: utilities.md#function.objects
285
- [future.syn]: #future.syn
286
- [futures]: #futures
287
- [futures.async]: #futures.async
288
- [futures.errors]: #futures.errors
289
- [futures.future.error]: #futures.future.error
290
- [futures.overview]: #futures.overview
291
- [futures.promise]: #futures.promise
292
- [futures.shared.future]: #futures.shared.future
293
- [futures.state]: #futures.state
294
- [futures.task]: #futures.task
295
- [futures.task.general]: #futures.task.general
296
- [futures.task.members]: #futures.task.members
297
- [futures.task.nonmembers]: #futures.task.nonmembers
298
- [futures.unique.future]: #futures.unique.future
299
- [intro.multithread]: basic.md#intro.multithread
300
- [intro.progress]: basic.md#intro.progress
301
- [intro.races]: basic.md#intro.races
302
- [latch.syn]: #latch.syn
303
- [limits.syn]: support.md#limits.syn
304
- [mutex.syn]: #mutex.syn
305
- [res.on.data.races]: library.md#res.on.data.races
306
- [res.on.exception.handling]: library.md#res.on.exception.handling
307
- [semaphore.syn]: #semaphore.syn
308
- [shared.mutex.syn]: #shared.mutex.syn
309
- [stdatomic.h.syn]: #stdatomic.h.syn
310
- [stopcallback]: #stopcallback
311
- [stopcallback.cons]: #stopcallback.cons
312
- [stopcallback.general]: #stopcallback.general
313
- [stopsource]: #stopsource
314
- [stopsource.cons]: #stopsource.cons
315
- [stopsource.general]: #stopsource.general
316
- [stopsource.mem]: #stopsource.mem
317
- [stopsource.nonmembers]: #stopsource.nonmembers
318
- [stoptoken]: #stoptoken
319
- [stoptoken.cons]: #stoptoken.cons
320
- [stoptoken.general]: #stoptoken.general
321
- [stoptoken.mem]: #stoptoken.mem
322
- [stoptoken.nonmembers]: #stoptoken.nonmembers
323
- [syserr]: diagnostics.md#syserr
324
- [syserr.syserr]: diagnostics.md#syserr.syserr
325
- [term.padding.bits]: basic.md#term.padding.bits
326
- [term.unevaluated.operand]: expr.md#term.unevaluated.operand
327
- [thread]: #thread
328
- [thread.barrier]: #thread.barrier
329
- [thread.barrier.class]: #thread.barrier.class
330
- [thread.barrier.general]: #thread.barrier.general
331
- [thread.condition]: #thread.condition
332
- [thread.condition.condvar]: #thread.condition.condvar
333
- [thread.condition.condvarany]: #thread.condition.condvarany
334
- [thread.condition.condvarany.general]: #thread.condition.condvarany.general
335
- [thread.condition.general]: #thread.condition.general
336
- [thread.condition.nonmember]: #thread.condition.nonmember
337
- [thread.condvarany.intwait]: #thread.condvarany.intwait
338
- [thread.condvarany.wait]: #thread.condvarany.wait
339
- [thread.coord]: #thread.coord
340
- [thread.coord.general]: #thread.coord.general
341
- [thread.general]: #thread.general
342
- [thread.jthread.class]: #thread.jthread.class
343
- [thread.jthread.class.general]: #thread.jthread.class.general
344
- [thread.jthread.cons]: #thread.jthread.cons
345
- [thread.jthread.mem]: #thread.jthread.mem
346
- [thread.jthread.special]: #thread.jthread.special
347
- [thread.jthread.static]: #thread.jthread.static
348
- [thread.jthread.stop]: #thread.jthread.stop
349
- [thread.latch]: #thread.latch
350
- [thread.latch.class]: #thread.latch.class
351
- [thread.latch.general]: #thread.latch.general
352
- [thread.lock]: #thread.lock
353
- [thread.lock.algorithm]: #thread.lock.algorithm
354
- [thread.lock.general]: #thread.lock.general
355
- [thread.lock.guard]: #thread.lock.guard
356
- [thread.lock.scoped]: #thread.lock.scoped
357
- [thread.lock.shared]: #thread.lock.shared
358
- [thread.lock.shared.cons]: #thread.lock.shared.cons
359
- [thread.lock.shared.general]: #thread.lock.shared.general
360
- [thread.lock.shared.locking]: #thread.lock.shared.locking
361
- [thread.lock.shared.mod]: #thread.lock.shared.mod
362
- [thread.lock.shared.obs]: #thread.lock.shared.obs
363
- [thread.lock.unique]: #thread.lock.unique
364
- [thread.lock.unique.cons]: #thread.lock.unique.cons
365
- [thread.lock.unique.general]: #thread.lock.unique.general
366
- [thread.lock.unique.locking]: #thread.lock.unique.locking
367
- [thread.lock.unique.mod]: #thread.lock.unique.mod
368
- [thread.lock.unique.obs]: #thread.lock.unique.obs
369
- [thread.mutex]: #thread.mutex
370
- [thread.mutex.class]: #thread.mutex.class
371
- [thread.mutex.general]: #thread.mutex.general
372
- [thread.mutex.recursive]: #thread.mutex.recursive
373
- [thread.mutex.requirements]: #thread.mutex.requirements
374
- [thread.mutex.requirements.general]: #thread.mutex.requirements.general
375
- [thread.mutex.requirements.mutex]: #thread.mutex.requirements.mutex
376
- [thread.mutex.requirements.mutex.general]: #thread.mutex.requirements.mutex.general
377
- [thread.once]: #thread.once
378
- [thread.once.callonce]: #thread.once.callonce
379
- [thread.once.onceflag]: #thread.once.onceflag
380
- [thread.req]: #thread.req
381
- [thread.req.exception]: #thread.req.exception
382
- [thread.req.lockable]: #thread.req.lockable
383
- [thread.req.lockable.basic]: #thread.req.lockable.basic
384
- [thread.req.lockable.general]: #thread.req.lockable.general
385
- [thread.req.lockable.req]: #thread.req.lockable.req
386
- [thread.req.lockable.shared]: #thread.req.lockable.shared
387
- [thread.req.lockable.shared.timed]: #thread.req.lockable.shared.timed
388
- [thread.req.lockable.timed]: #thread.req.lockable.timed
389
- [thread.req.native]: #thread.req.native
390
- [thread.req.paramname]: #thread.req.paramname
391
- [thread.req.timing]: #thread.req.timing
392
- [thread.sema]: #thread.sema
393
- [thread.sema.cnt]: #thread.sema.cnt
394
- [thread.sema.general]: #thread.sema.general
395
- [thread.sharedmutex.class]: #thread.sharedmutex.class
396
- [thread.sharedmutex.requirements]: #thread.sharedmutex.requirements
397
- [thread.sharedmutex.requirements.general]: #thread.sharedmutex.requirements.general
398
- [thread.sharedtimedmutex.class]: #thread.sharedtimedmutex.class
399
- [thread.sharedtimedmutex.requirements]: #thread.sharedtimedmutex.requirements
400
- [thread.sharedtimedmutex.requirements.general]: #thread.sharedtimedmutex.requirements.general
401
- [thread.stoptoken]: #thread.stoptoken
402
- [thread.stoptoken.intro]: #thread.stoptoken.intro
403
- [thread.stoptoken.syn]: #thread.stoptoken.syn
404
- [thread.summary]: #thread.summary
405
- [thread.syn]: #thread.syn
406
- [thread.thread.algorithm]: #thread.thread.algorithm
407
- [thread.thread.assign]: #thread.thread.assign
408
- [thread.thread.class]: #thread.thread.class
409
- [thread.thread.class.general]: #thread.thread.class.general
410
- [thread.thread.constr]: #thread.thread.constr
411
- [thread.thread.destr]: #thread.thread.destr
412
- [thread.thread.id]: #thread.thread.id
413
- [thread.thread.member]: #thread.thread.member
414
- [thread.thread.static]: #thread.thread.static
415
- [thread.thread.this]: #thread.thread.this
416
- [thread.threads]: #thread.threads
417
- [thread.threads.general]: #thread.threads.general
418
- [thread.timedmutex.class]: #thread.timedmutex.class
419
- [thread.timedmutex.recursive]: #thread.timedmutex.recursive
420
- [thread.timedmutex.requirements]: #thread.timedmutex.requirements
421
- [thread.timedmutex.requirements.general]: #thread.timedmutex.requirements.general
422
- [time]: time.md#time
423
- [time.clock]: time.md#time.clock
424
- [time.clock.req]: time.md#time.clock.req
425
- [time.duration]: time.md#time.duration
426
- [time.point]: time.md#time.point
427
- [unord.hash]: utilities.md#unord.hash
428
- [util.sharedptr]: mem.md#util.sharedptr
429
- [util.smartptr.atomic]: #util.smartptr.atomic
430
- [util.smartptr.atomic.general]: #util.smartptr.atomic.general
431
- [util.smartptr.atomic.shared]: #util.smartptr.atomic.shared
432
- [util.smartptr.atomic.weak]: #util.smartptr.atomic.weak
433
-
434
- [^1]: Implementations for which standard time units are meaningful will
435
- typically have a steady clock within their hardware implementation.
436
-
437
- [^2]: That is, atomic operations on the same memory location via two
438
- different addresses will communicate atomically.
 
20
  public:
21
  // construction and destruction
22
  packaged_task() noexcept;
23
  template<class F>
24
  explicit packaged_task(F&& f);
25
+ template<class F, class Allocator>
26
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
27
  ~packaged_task();
28
 
29
  // no copy
30
  packaged_task(const packaged_task&) = delete;
31
  packaged_task& operator=(const packaged_task&) = delete;
 
65
  ``` cpp
66
  template<class F>
67
  explicit packaged_task(F&& f);
68
  ```
69
 
70
+ *Effects:* Equivalent to
71
+ `packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f))`.
72
+
73
+ ``` cpp
74
+ template<class F, class Allocator>
75
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
76
+ ```
77
+
78
  *Constraints:* `remove_cvref_t<F>` is not the same type as
79
  `packaged_task<R(ArgTypes...)>`.
80
 
81
+ *Mandates:* `is_invocable_r_v<R, decay_t<F>&, ArgTypes...>` is `true`.
82
 
83
+ *Preconditions:* `Allocator` meets the *Cpp17Allocator*
84
+ requirements [[allocator.requirements.general]].
85
 
86
+ *Effects:* Let `A2` be
87
+ `allocator_traits<Allocator>::rebind_alloc<`*`unspecified`*`>` and let
88
+ `a2` be an object of type `A2` initialized with `A2(a)`. Constructs a
89
+ new `packaged_task` object with a stored task of type `decay_t<F>` and a
90
+ shared state. Initializes the object’s stored task with
91
+ `std::forward<F>(f)`. Uses `a2` to allocate storage for the shared state
92
+ and stores a copy of `a2` in the shared state.
93
 
94
+ *Throws:* Any exceptions thrown by the initialization of the stored
95
+ task. If storage for the shared state cannot be allocated, any exception
96
+ thrown by `A2::allocate`.
97
 
98
  ``` cpp
99
  template<class F> packaged_task(F) -> packaged_task<see below>;
100
  ```
101
 
 
205
  in `args...`. If the task returns normally, the return value is stored
206
  as the asynchronous result in the shared state of `*this`, otherwise the
207
  exception thrown by the task is stored. In either case, this is done
208
  without making that state ready [[futures.state]] immediately. Schedules
209
  the shared state to be made ready when the current thread exits, after
210
+ all objects with thread storage duration associated with the current
211
  thread have been destroyed.
212
 
213
  *Throws:* `future_error` if an error condition occurs.
214
 
215
  *Error conditions:*
 
220
 
221
  ``` cpp
222
  void reset();
223
  ```
224
 
225
+ *Effects:* Equivalent to:
226
+
227
+ ``` cpp
228
+ if (!valid()) {
229
+ throw future_error(future_errc::no_state);
230
+ }
231
+ *this = packaged_task(allocator_arg, a, std::move(f));
232
+ ```
233
+
234
+ where `f` is the task stored in `*this` and `a` is the allocator stored
235
+ in the shared state.
236
 
237
  [*Note 2*: This constructs a new shared state for `*this`. The old
238
  state is abandoned [[futures.state]]. — *end note*]
239
 
240
  *Throws:*
241
 
242
+ - Any exception thrown by the `packaged_task` constructor.
 
 
243
  - `future_error` with an error condition of `no_state` if `*this` has no
244
  shared state.
245
 
246
  #### Globals <a id="futures.task.nonmembers">[[futures.task.nonmembers]]</a>
247
 
 
250
  void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
251
  ```
252
 
253
  *Effects:* As if by `x.swap(y)`.
254