Title
packaged_task::reset() memory allocation
Status
resolved
Section
[futures.task.members]
Submitter
Jonathan Wakely

Created on 2013-03-05.00:00:00 last changed 93 months ago

Messages

Date: 2017-03-14.02:29:49

Proposed resolution:

This wording is relative to N4606

  1. Change [futures.task.members] as indicated:

    void reset();
    

    -22- Effects:

    • if the shared state associated with *this was created via the packaged_task(F&& f) constructor, aAs if *this = packaged_task(std::move(f)), where f is the task stored in *this.

    • if the shared state associated with *this was created via the packaged_task(allocator_arg_t, Allocator& a, F&&) constructor, as if *this = packaged_task(allocator_arg, a, std::move(f)), where a is the allocator used to allocate the shared state associated with *this, and f is the task stored in *this.

    [Note: This constructs a new shared state for *this. The old state is abandoned (30.6.4). — end note]

    -23- Throws:

    • if no allocator was used, bad_alloc if memory for the new shared state could not be allocated.

    • if an allocator was used, any exception thrown by std::allocator_traits<Allocator>::template rebind_traits<unspecified>::allocate.

    • any exception thrown by the move constructor of the task stored in the shared state.

    • future_error with an error condition of no_state if *this has no shared state.

Date: 2017-03-15.00:00:00

[ 2017-03-03, Kona ]

This was resolved by adopting 2921, which removed the constructors that take allocators.

Date: 2016-09-08.00:00:00

[ 2016-09-08 ]

Alisdair requests change to Review.

Date: 2016-08-02.00:00:00

[ 2016-08-02 Chicago, Billy O'Neal comments and suggests concrete wording ]

Talked this over with Alasdair, who says there's little desire to allow the packaged_task to be change allocators after initial construction, making what libstdc++ does already the "right thing." A clarification note is still necessary to indicate that the allocator supplied to the allocator_arg_t constructor is to be used.

Wed PM: Move to Tentatively Ready

Date: 2015-05-08.04:23:26

[ 2015-05 Lenexa, SG1 response ]

No strong opinions in SG1, and this is really an LWG issue. Back to you.

Date: 2015-04-04.16:45:17

[ 2015-02 Cologne ]

Handed over to SG1.

Date: 2013-03-17.21:43:03

The effects of packaged_task::reset() result in memory allocation, but don't allow a user to provide an allocator.

packaged_task::reset() needs to be overloaded like so:

template<class Alloc>  
void reset(const Alloc&);

Alternatively, the effects of reset() need to require the same allocator is used as at construction, which would require the constructor to store the allocator for later use.

I like to remark that GCC at the moment uses the second option, i.e. the allocator passed to the constructor (if any) is used to create the new shared state, because this didn't require any change to the interface.

History
Date User Action Args
2017-03-14 02:29:49adminsetmessages: + msg9098
2017-03-14 02:29:49adminsetstatus: review -> resolved
2016-09-27 18:32:24adminsetmessages: + msg8521
2016-09-27 18:32:24adminsetstatus: ready -> review
2016-08-04 03:06:12adminsetstatus: open -> ready
2016-08-03 17:05:16adminsetmessages: + msg8365
2016-08-03 17:05:16adminsetmessages: + msg8364
2015-05-08 04:23:26adminsetmessages: + msg7395
2015-04-04 16:45:17adminsetmessages: + msg7329
2015-04-04 16:45:17adminsetstatus: new -> open
2013-03-05 00:00:00admincreate