Projekt

Allgemein

Profil

Event loop chain » Historie » Version 2

Maximilian Seesslen, 16.03.2026 15:25

1 1 Maximilian Seesslen
h1. Event loop chain
2
3
<pre><code class="cpp">
4
#include <stdlib.h>
5
#include <stdint.h>
6
#include <stdio.h>
7
8
#include "/home/deseessm/wp/src/canswitch/liblepto/include/lepto/signal.h"
9
10
class CEventLoop
11
{
12
   private:
13
      static CEventLoop* m_first;
14
      CEventLoop* m_next=nullptr;
15
16
   public:
17
      CEventLoop()
18
      {
19
         if(!m_first)
20
         {
21
            m_first=this;
22
         }
23
         else
24
         {
25
            CEventLoop* p=m_first;
26
            while( p->m_next)
27
            {
28
               p=p->m_next;
29
            }
30
            p->m_next=this;
31
         }
32
      }
33
      virtual void eventLoop()
34
      {
35
         printf("L %p\n", this);
36
      }
37
      static void allEventLoops()
38
      {
39
         CEventLoop* p=m_first;
40
         while(p)
41
         {
42
            p->eventLoop();
43
            p=p->m_next;
44
         }
45
      }
46
};
47
48
CEventLoop* CEventLoop::m_first = nullptr;
49
</pre>
50 2 Maximilian Seesslen
51
Ein Problem ist, das bei jedem richtigen aufwecken durch Daten die komplette Kette durchlaufen werden muss. Der Signal-Pool-Static koennte helfen.
52
Wie hoch ist der overhead? Spuerbar relevant? Mit GPIO ansehen.
53
54
Usecase:
55
   Button:
56
      On press/release:
57
         postPhoneEmit();
58
      eventLoop();
59
60
Theoretisch kann sich der Button aus der eventLoop rausnehmen. Deactivate evtl wirklich besser als virtual tables durchzugehen.