Skip to content

Commit 5b0d3f7

Browse files
committed
avr_coro_status* -> avr_coro_state.
1 parent 3b5eab5 commit 5b0d3f7

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

avrcoro.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
#ifdef __AVR__
1212

13-
/* Coroutine status codes */
14-
typedef enum avr_coro_status_t_ {
15-
AVR_CORO_SLEEPING = 1,
13+
/* Coroutine state codes */
14+
typedef enum avr_coro_state_t_ {
15+
AVR_CORO_SLEEPING = 0,
1616
AVR_CORO_RUNNING,
1717
AVR_CORO_DEAD,
1818
AVR_CORO_ILLEGAL,
19-
} avr_coro_status_t;
19+
} avr_coro_state_t;
2020

2121
typedef struct avr_coro_t_ {
2222
char status;
@@ -36,7 +36,7 @@ extern int avr_coro_init(avr_coro_t *coro,
3636
avr_coro_func_t func);
3737
extern int avr_coro_resume(avr_coro_t *coro, void **data);
3838
extern int avr_coro_yield(avr_coro_t *self, void **data);
39-
extern avr_coro_status_t avr_coro_status(const avr_coro_t *coro);
39+
extern avr_coro_state_t avr_coro_state(const avr_coro_t *coro);
4040
#ifdef __cplusplus
4141
}
4242
#endif /*__cplusplus */

avrcoro_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ int avr_coro_yield(avr_coro_t *self, void **data)
7676
return 0;
7777
}
7878

79-
avr_coro_status_t avr_coro_status(const avr_coro_t *coro)
79+
avr_coro_state_t avr_coro_state(const avr_coro_t *coro)
8080
{
81-
return coro == NULL ? AVR_CORO_ILLEGAL : (avr_coro_status_t)coro->status;
81+
return coro == NULL || (coro->status >= AVR_CORO_SLEEPING && coro->status < AVR_CORO_ILLEGAL) ? AVR_CORO_ILLEGAL : (avr_coro_state_t)coro->status;
8282
}
8383

8484
#endif /* __AVR__ */

examples/Coroutines/02.Symmetric_Coroutines_via_Asymmetric_Ones/02.Symmetric_Coroutines_via_Asymmetric_Ones.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void coroutines_example(void)
102102
// Stop when a coroutine has died (the function returned).
103103
// Please notice that in this case only one of the coroutines
104104
// reaches the point when its function returns.
105-
if (avr_coro_status(&coroutine_state[yield_to]) == AVR_CORO_DEAD)
105+
if (avr_coro_state(&coroutine_state[yield_to]) == AVR_CORO_DEAD)
106106
{
107107
break;
108108
}

0 commit comments

Comments
 (0)