Closed BillyONeal closed 4 years ago
(I'm willing to submit a PR fixing this but any solution I can think of is invasive enough that I want to ask what you want first)
I'm not sure that placement new is the correct approach for the multi_producer_sequencer
call-site as the call to std::make_unique<std::atomic<SEQUENCE>[]>(bufferSize)
above should have already created the atomic objects and called the default constructors. We just need to assign the atomic objects values.
I guess the cheapest way to initialize the values now is by calling .store(seq, std::memory_order_relaxed)
?
I think the use of std::atomic_init()
in cancellation_registration_list_chunk::allocate()
should be ok to unconditionally be converted to placement new since it was previously uninitialized memory.
I should really replace cancellation_token with stop_token at some stage anyway.
Ah yes, I missed the make_unique
.
For the cancellation_token ones is there a specific reason it's calling malloc rather than new? It looks like new would just do the right thing.
Oh, because it's using an array of size 1 like a FAM. Disregard!
It looks like the placement new can be used unconditionally because C++11 even has the constructor taking a T.
P0883 marks atomic_init as deprecated, which causes cppcoro to throw a bunch of deprecation errors when used with our standard library (post https://github.com/microsoft/STL/pull/390 ).
Should the places calling
atomic_init
be changed to do something like:instead?