Ignore:
Timestamp:
2019-07-02T11:17:14Z (5 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d71d09
Parents:
09170ab8
Message:

cpp: add allocator support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/__bits/thread/packaged_task.hpp

    r09170ab8 r5ea9dd2  
    3232#include <__bits/exception.hpp>
    3333#include <__bits/functional/function.hpp>
     34#include <__bits/memory/allocator_traits.hpp>
    3435#include <__bits/thread/future.hpp>
    3536#include <__bits/thread/future_common.hpp>
     
    7475            >
    7576            explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f)
    76                 : packaged_task{forward<F>(f)}
    77             {
    78                 // TODO: use the allocator
     77                : func_{forward<F>(f)}, state_{}
     78            {
     79                auto rebound = allocator_traits<Allocator>::rebind<
     80                    aux::shared_state<R>
     81                >{a};
     82
     83                state_ = rebound.allocate(1);
     84                rebound.construct(state_);
    7985            }
    8086
Note: See TracChangeset for help on using the changeset viewer.