Projekt

Allgemein

Profil

Event loop chain » Historie » Revision 2

Revision 1 (Maximilian Seesslen, 10.09.2025 11:39) → Revision 2/3 (Maximilian Seesslen, 16.03.2026 15:25)

h1. Event loop chain



<pre><code class="cpp">
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

#include "/home/deseessm/wp/src/canswitch/liblepto/include/lepto/signal.h"

class CEventLoop
{
private:
static CEventLoop* m_first;
CEventLoop* m_next=nullptr;

public:
CEventLoop()
{
if(!m_first)
{
m_first=this;
}
else
{
CEventLoop* p=m_first;
while( p->m_next)
{
p=p->m_next;
}
p->m_next=this;
}
}
virtual void eventLoop()
{
printf("L %p\n", this);
}
static void allEventLoops()
{
CEventLoop* p=m_first;
while(p)
{
p->eventLoop();
p=p->m_next;
}
}
};

CEventLoop* CEventLoop::m_first = nullptr;
</pre>

Ein Problem ist, das bei jedem richtigen aufwecken durch Daten die komplette Kette durchlaufen werden muss. Der Signal-Pool-Static koennte helfen.
Wie hoch ist der overhead? Spuerbar relevant? Mit GPIO ansehen.

Usecase:
Button:
On press/release:
postPhoneEmit();
eventLoop();

Theoretisch kann sich der Button aus der eventLoop rausnehmen. Deactivate evtl wirklich besser als virtual tables durchzugehen.