summaryrefslogtreecommitdiff
path: root/code/ecp/timer.h
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
committerUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
commit0d0e9facfcea3cf96da3b63285865182fdd5477e (patch)
treecca42e7aab184cad981c794073a4376aa2616193 /code/ecp/timer.h
parent05e11f491b84a110b9ca08612df370b91e9bdcbc (diff)
refatoring dirs
Diffstat (limited to 'code/ecp/timer.h')
-rw-r--r--code/ecp/timer.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/code/ecp/timer.h b/code/ecp/timer.h
new file mode 100644
index 0000000..8863226
--- /dev/null
+++ b/code/ecp/timer.h
@@ -0,0 +1,39 @@
+#define ECP_MAX_TIMER 8
+
+#define ECP_ERR_MAX_TIMER -110
+
+#include <stddef.h>
+
+#ifdef ECP_WITH_PTHREAD
+#include <pthread.h>
+#endif
+
+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); \ No newline at end of file