Re: [PATCH 5/6] gdb/continuations: use lambdas instead of function pointers

Tom Tromey
2021-04-22T12:50:19Z

>>>>> ">" == Aktemur, Tankut Baris <tankut.baris.aktemur@intel.com> writes:

>> The continuations at the moment are rather plain, but just in case a
>> continuation in the future adds more continuations, delaying the pop
>> could cause a wrong element to be popped, I'm afraid. How about the
>> following? (The same is to be used in Patch 6/6, too).

>> @@ -122,7 +39,12 @@ void
>> do_all_inferior_continuations ()
>> {
>> struct inferior *inf = current_inferior ();
>> - do_my_continuations (&inf->continuations);
>> + while (!inf->continuations.empty ())
>> + {
>> + auto iter = inf->continuations.begin ();
>> + (*iter) ();
>> + inf->continuations.erase (iter);

It took me a minute to see what was going on here, at first I misread it
a bit. But yeah, I see, I think this is fine.

If elements are only ever added/popped from the front, maybe
std::forward_list is preferable.

>> Out of curiosity, how do you pronounce 'std'? I was just thinking if it
>> should be "a std::function" or "an std::function". I pronounce std as
>> "ess-tee-dee" and "an" sounded more natural to me.

Hah, I didn't even think about that. In my head it sounds like "sted",
but that's just something I made up myself. Either way is fine by me,
or even just not referring to the type, since that's clear from context.

Tom