A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/futures.task below:

33 Thread support library [thread]

When the packaged_­task object is invoked, its stored task is invoked and the result (whether normal or exceptional) stored in the shared state. Any futures that share the shared state will then be able to access the stored result.

namespace std {
  template<class> class packaged_task; 
  template<class R, class... ArgTypes>
  class packaged_task<R(ArgTypes...)> {
  public:
        packaged_task() noexcept;
    template <class F>
      explicit packaged_task(F&& f);
    ~packaged_task();

        packaged_task(const packaged_task&) = delete;
    packaged_task& operator=(const packaged_task&) = delete;

        packaged_task(packaged_task&& rhs) noexcept;
    packaged_task& operator=(packaged_task&& rhs) noexcept;
    void swap(packaged_task& other) noexcept;

    bool valid() const noexcept;

        future<R> get_future();

        void operator()(ArgTypes... );
    void make_ready_at_thread_exit(ArgTypes...);

    void reset();
  };
  template <class R, class... ArgTypes>
    void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
  template <class R, class Alloc>
    struct uses_allocator<packaged_task<R>, Alloc>;
}
33.6.10.1 packaged_­task member functions [futures.task.members]

packaged_task() noexcept;

Effects: Constructs a packaged_­task object with no shared state and no stored task.

template <class F> packaged_task(F&& f);

Requires: INVOKE<R>(f, t1, t2, ..., tN), where t1, t2, ..., tN are values of the corresponding types in ArgTypes..., shall be a valid expression. Invoking a copy of f shall behave the same as invoking f.

Remarks: This constructor shall not participate in overload resolution if decay_­t<F> is the same type as packaged_­task<R(ArgTypes...)>.

Effects: Constructs a new packaged_­task object with a shared state and initializes the object's stored task with std​::​forward<F>(f).

Throws:

packaged_task(packaged_task&& rhs) noexcept;

Effects: Constructs a new packaged_­task object and transfers ownership of rhs's shared state to *this, leaving rhs with no shared state. Moves the stored task from rhs to *this.

Postconditions: rhs has no shared state.

packaged_task& operator=(packaged_task&& rhs) noexcept;

Effects:

~packaged_task();

void swap(packaged_task& other) noexcept;

Effects: Exchanges the shared states and stored tasks of *this and other.

Postconditions: *this has the same shared state and stored task (if any) as other prior to the call to swap. other has the same shared state and stored task (if any) as *this prior to the call to swap.

bool valid() const noexcept;

Returns: true only if *this has a shared state.

future<R> get_future();

Returns: A future object that shares the same shared state as *this.

Throws: a future_­error object if an error occurs.

Error conditions:

void operator()(ArgTypes... args);

Effects: As if by INVOKE<R>(f, t1, t2, ..., tN), where f is the stored task of *this and t1, t2, ..., tN are the values in args.... If the task returns normally, the return value is stored as the asynchronous result in the shared state of *this, otherwise the exception thrown by the task is stored. The shared state of *this is made ready, and any threads blocked in a function waiting for the shared state of *this to become ready are unblocked.

Throws: a future_­error exception object if there is no shared state or the stored task has already been invoked.

Error conditions:

void make_ready_at_thread_exit(ArgTypes... args);

Effects: As if by INVOKE<R>(f, t1, t2, ..., tN), where f is the stored task and t1, t2, ..., tN are the values in args.... If the task returns normally, the return value is stored as the asynchronous result in the shared state of *this, otherwise the exception thrown by the task is stored. In either case, this shall be done without making that state ready ([futures.state]) immediately. Schedules the shared state to be made ready when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed.

Throws: future_­error if an error condition occurs.

Error conditions:

void reset();

Effects: As if *this = packaged_­task(std​::​move(f)), where f is the task stored in *this. [Note: This constructs a new shared state for *this. The old state is abandoned ([futures.state]). end note]

Throws:

33.6.10.2 packaged_­task globals [futures.task.nonmembers]

template <class R, class... ArgTypes> void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;

Effects: As if by x.swap(y).

template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc> : true_type { };


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4