Turns out changing EnqueueAndLogEvent
into a macro has some implications that are making this infeasible. Consider:
0#define ENQUEUE_AND_LOG_EVENT(event, fmt, ...) \
1 do { \
2 LOG_EVENT("Enqueuing " fmt, __VA_ARGS__); \
3 m_internals->m_schedulerClient.AddToProcessQueue([event, fmt, __VA_ARGS__, this] { \
4 LOG_EVENT(fmt, __VA_ARGS__); \
5 event(); \
6 }); \
7 } while (0)
8
9#define LOG_EVENT(fmt, ...) \
10 LogPrint(BCLog::VALIDATIONINTERFACE, fmt "\n", __VA_ARGS__);
The problem is that the capture list is expecting variables but the call sites are providing expressions. So unfortunately this won’t compile. Presumably, if this did work, the expressions in the lambda would be evaluated thus defeating the purpose.
Unless there is a creative solution that I’m unaware of, the only alternative I can think of is to forgo the macro and duplicate the LogPrint
for the enqueuing in each method. Thoughts?