Date: Sun, 19 Feb 2023 20:50:32 +0000
On Sun, Feb 19, 2023 at 7:25 PM Arthur O'Dwyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I did get nerdsniped enough to implement a `class ReentryPreventer` synchronization primitive along Frederick's lines
I'll spend more time tomorrow looking at your code in more detail.
> but the example on Page 6 seems unimplementable without a ton of heap-allocation, which obviously won't fly even as a library solution.
I take it you mean that the 'std::set' would do a load of allocating
and deallocating. We could replace std::set with a statically-sized
container that doesn't do any allocating, for example:
class set_of_thread_ids {
std::thread::id buf[16u]; // MAX_THREADS == 16u
public:
void insert(std::thread::id);
void erase(std::thread::id);
bool contains(std::thread::id);
};
> The trick, as always, is to figure out what you want this class type to do, and then implement that.
> Right now Frederick has it "doing" about 10 different things, which makes it impossible to implement, of course.
> You have to figure out in words what it does, first; and then you can implement it from that.
The figure is more like 75ish when you consider all the ways that
"noreentry_this_object" can be combined with "noreentry_all_objects".
<std-proposals_at_[hidden]> wrote:
>
> I did get nerdsniped enough to implement a `class ReentryPreventer` synchronization primitive along Frederick's lines
I'll spend more time tomorrow looking at your code in more detail.
> but the example on Page 6 seems unimplementable without a ton of heap-allocation, which obviously won't fly even as a library solution.
I take it you mean that the 'std::set' would do a load of allocating
and deallocating. We could replace std::set with a statically-sized
container that doesn't do any allocating, for example:
class set_of_thread_ids {
std::thread::id buf[16u]; // MAX_THREADS == 16u
public:
void insert(std::thread::id);
void erase(std::thread::id);
bool contains(std::thread::id);
};
> The trick, as always, is to figure out what you want this class type to do, and then implement that.
> Right now Frederick has it "doing" about 10 different things, which makes it impossible to implement, of course.
> You have to figure out in words what it does, first; and then you can implement it from that.
The figure is more like 75ish when you consider all the ways that
"noreentry_this_object" can be combined with "noreentry_all_objects".
Received on 2023-02-19 20:50:41