Changeset 5ea9dd2 in mainline


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

Location:
uspace/lib/cpp/include/__bits/thread
Files:
2 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
  • uspace/lib/cpp/include/__bits/thread/promise.hpp

    r09170ab8 r5ea9dd2  
    3131
    3232#include <__bits/exception.hpp>
     33#include <__bits/memory/allocator_traits.hpp>
    3334#include <__bits/thread/future.hpp>
    3435#include <__bits/thread/shared_state.hpp>
     
    5455                template<class Allocator>
    5556                promise_base(allocator_arg_t, const Allocator& a)
    56                     : promise_base{}
    57                 {
    58                     // TODO: Use the allocator.
     57                    : state_{}
     58                {
     59                    auto rebound = allocator_traits<Allocator>::rebind<
     60                        aux::shared_state<R>
     61                    >{a};
     62
     63                    state_ = rebound.allocate(1);
     64                    rebound.construct(state_);
    5965                }
    6066
     
    148154
    149155            template<class Allocator>
    150             promise(allocator_arg_t, const Allocator& a)
    151                 : aux::promise_base<R>{}
    152             {
    153                 // TODO: Use the allocator.
    154             }
     156            promise(allocator_arg_t tag, const Allocator& a)
     157                : aux::promise_base<R>{tag, a}
     158            { /* DUMMY BODY */ }
    155159
    156160            promise(promise&& rhs) noexcept
     
    250254
    251255            template<class Allocator>
    252             promise(allocator_arg_t, const Allocator& a)
    253                 : aux::promise_base<R*>{}
    254             {
    255                 // TODO: Use the allocator.
    256             }
     256            promise(allocator_arg_t tag, const Allocator& a)
     257                : aux::promise_base<R*>{tag, a}
     258            { /* DUMMY BODY */ }
    257259
    258260            promise(promise&& rhs) noexcept
     
    323325
    324326            template<class Allocator>
    325             promise(allocator_arg_t, const Allocator& a)
    326                 : aux::promise_base<void>{}
    327             {
    328                 // TODO: Use the allocator.
    329             }
     327            promise(allocator_arg_t tag, const Allocator& a)
     328                : aux::promise_base<void>{tag, a}
     329            { /* DUMMY BODY */ }
    330330
    331331            promise(promise&& rhs) noexcept
Note: See TracChangeset for help on using the changeset viewer.