|
From: | Leon Woestenberg |
Subject: | Re: [lwip-users] OS-less Active Web Server with RAW API. |
Date: | Fri, 09 Jul 2004 00:46:53 +0200 |
User-agent: | Mozilla Thunderbird 0.7.1 (Windows/20040626) |
Hello,
(simplified) example: typedef enum { STATE1, STATE2, STATE3 } state; void init() { state = STATE1; } void task() { switch (state) {case STATE1: /*do some work*/ state = STATE2; break; case STATE2: /*do some work*/ state = STATE3; break; case STATE3: /*do some work*/ state = STATE1; break;} }
We do exactly the same on some 8 "tasks" or so. Works perfectly for simple systems.I have seen (smarter) approaches where the state variable is a pointer to the next state function. Each state has its own function. This gets rid of the switch statement.
Regards, Leon.
[Prev in Thread] | Current Thread | [Next in Thread] |