| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #ifndef __THREAD_Hx__
- #define __THREAD_Hx__
- #include <pthread.h>
- #include <stdio.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define KB 1024
- #define MB (KB*KB)
- enum {
- THREAD_ID_WS=0,
- THREAD_ID_WEB,
- THREAD_ID_SNMP,
- THREAD_ID_POWER,
- THREAD_ID_POLL,
- THREAD_ID_MQTT,
- THREAD_ID_MAIL,
- THREAD_ID_UI,
-
- THREAD_ID_MAX
- };
- typedef void *(*thread_fn)(void *arg);
- typedef struct {
- const char *name;
- thread_fn fn;
- void *arg;
- int stksz;
- int prio;
- }thread_attr_t;
- typedef struct {
- const char *name;
- pthread_t tid;
- int quit;
- int running;
- void *arg;
- thread_fn fn;
- void *stk;
- }thread_handle_t;
- int thread_start(int id, thread_fn fn, void *arg);
- int thread_start2(int id);
- int thread_restart(int id);
- int thread_startEx(int id, const char *name, thread_fn fn, void *arg, int stksz, int prio);
- int thread_stop(int id);
- int thread_stop_all(void);
- int thread_is_running(int id);
- int thread_start_simp(thread_fn fn, void *arg, int stksz);
- int thread_print_stacksize(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|