Will `std :: future :: then` allocate memory? Is it possible to use a custom allocator?

std::promisehas a constructor that allocates the memory used to store the general state. In the implementations .thenthat I have seen so far, one stores the function in an erasable form, similar std::functionin general condition. The concurrency stlab library even goes so far as to put

using then_t = std::vector<std::pair<executor_t, task<void()>>>;

into a shared state (to enable shared futures).

Is there an intention to indicate whether a distributor can be specified to continue?

In P0443R3 they say in 1.2.9 Properties for setting memory allocation

Implementer implementations must use the provided allocator to allocate any memory needed to store the presented functional object.

I think this means that the repository for agents represented through functions executeis not a pointer in the std::futureshared state .

I reviewed recent offers for futures or performers, and I could not find anything. Recent publications seem to help performers in the overall state of the future anyway. If an artist has an appropriate custom allocator, should this be used?

It seems to me that I missed something.

-

: , , , . - , :

template <typename Executor, typename T>
struct shared_state_t {
    // some prevention from race condition, for example
    std::atomic<unsigned> flags;
    // some sort of exception or value representation, for example
    std::variant<std::exception_ptr, T> maybe_value;
    // some handle to continuation
    continuation_t<Executor, T> continuation;
};

continuation_t<Executor, T> . Executor - std::function<void(T&&)> .

+4

Source: https://habr.com/ru/post/1688951/


All Articles