EasyGUI  Version v1.0
Local continuations


file  lc-addrlabels.h
file  lc-switch.h
file  lc.h


#define LC_INIT(s)   s = NULL
#define LC_RESUME(s)
#define LC_CONCAT2(s1, s2)   s1##s2
#define LC_CONCAT(s1, s2)   LC_CONCAT2(s1, s2)
#define LC_SET(s)
#define LC_END(s)
#define MY_CAT(x, y)   MY_CAT2(x, y)
#define MY_CAT2(x, y)   x##y
#define LC_INIT(s)   s = 0;
#define LC_RESUME(s)   switch(s) { case 0:
#define LC_SET(s)   s = (unsigned short)MY_CAT(__LINE__, U); case (unsigned short)MY_CAT(__LINE__, U):
#define LC_END(s)   }
#define LC_INIT(lc)
#define LC_SET(lc)
#define LC_RESUME(lc)
#define LC_END(lc)


typedef void * lc_t
typedef unsigned short lc_t

Detailed Description

Local continuations form the basis for implementing protothreads. A local continuation can be set in a specific function to capture the state of the function. After a local continuation has been set can be resumed in order to restore the state of the function at the point where the local continuation was set.

Macro Definition Documentation


#define LC_END (   lc)

Mark the end of local continuation usage.

The end operation signifies that local continuations should not be used any more in the function. This operation is not needed for most implementations of local continuation, but is required by a few implementations.


#define LC_INIT (   lc)

Initialize a local continuation.

This operation initializes the local continuation, thereby unsetting any previously set continuation state.

◆ LC_RESUME [1/2]

#define LC_RESUME (   s)
do { \
if(s != NULL) { \
goto *s; \
} \
} while(0)

◆ LC_RESUME [2/2]

#define LC_RESUME (   lc)

Resume a local continuation.

The resume operation resumes a previously set local continuation, thus restoring the state in which the function was when the local continuation was set. If the local continuation has not been previously set, the resume operation does nothing.

◆ LC_SET [1/2]

#define LC_SET (   s)
do { \
(s) = &&LC_CONCAT(LC_LABEL, __LINE__); \
} while(0)

◆ LC_SET [2/2]

#define LC_SET (   lc)

Set a local continuation.

The set operation saves the state of the function at the point where the operation is executed. As far as the set operation is concerned, the state of the function does not include the call-stack or local (automatic) variables, but only the program counter and such CPU registers that needs to be saved.

Typedef Documentation

◆ lc_t

typedef lc_t

The local continuation type.