diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:38:22 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:38:22 +0200 |
commit | 5cd610a07468137066ea4daa5176c3e7045113b0 (patch) | |
tree | a6a5b572572f8f37ec2cb87332fa46e9bcc53aa7 /ecp/src/timer.h | |
parent | 2473a7d5c51806ab8651cd3c4e07a15b62084eb5 (diff) |
ecp moved to root; fixed utils and tests
Diffstat (limited to 'ecp/src/timer.h')
-rw-r--r-- | ecp/src/timer.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ecp/src/timer.h b/ecp/src/timer.h new file mode 100644 index 0000000..5bccff1 --- /dev/null +++ b/ecp/src/timer.h @@ -0,0 +1,33 @@ +#define ECP_MAX_TIMER 8 + +#define ECP_ERR_MAX_TIMER -110 + +struct ECPTimerItem; + +typedef ssize_t (*ecp_timer_retry_t) (struct ECPConnection *, struct ECPTimerItem *); + +typedef struct ECPTimerItem { + struct ECPConnection *conn; + unsigned char mtype; + short cnt; + ecp_cts_t abstime; + ecp_cts_t timeout; + ecp_timer_retry_t retry; +} ECPTimerItem; + +typedef struct ECPTimer { + ECPTimerItem item[ECP_MAX_TIMER]; + short head; +#ifdef ECP_WITH_PTHREAD + pthread_mutex_t mutex; +#endif +} ECPTimer; + +int ecp_timer_create(ECPTimer *timer); +void ecp_timer_destroy(ECPTimer *timer); +int ecp_timer_item_init(ECPTimerItem *ti, struct ECPConnection *conn, unsigned char mtype, short cnt, ecp_cts_t timeout); +int ecp_timer_push(ECPTimerItem *ti); +void ecp_timer_pop(struct ECPConnection *conn, unsigned char mtype); +void ecp_timer_remove(struct ECPConnection *conn); +ecp_cts_t ecp_timer_exe(struct ECPSocket *sock); +ssize_t ecp_timer_send(struct ECPConnection *conn, ecp_timer_retry_t send_f, unsigned char mtype, short cnt, ecp_cts_t timeout); |