summaryrefslogtreecommitdiffstats
path: root/src/task.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 23:06:18 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 23:06:18 +0100
commitf8a2fec8f399229d15d3481be0ce8567b2ed6851 (patch)
treec214fcb30a99791dabe3076ea8c449b3d6538c89 /src/task.h
parent1d18f972554c8bad0f08b3ff6727c87586e97094 (diff)
downloadfastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.tar
fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.zip
Simplify queue functions
Diffstat (limited to 'src/task.h')
-rw-r--r--src/task.h25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/task.h b/src/task.h
index 733b671..367502e 100644
--- a/src/task.h
+++ b/src/task.h
@@ -41,42 +41,37 @@ typedef enum _fastd_task_type {
} fastd_task_type;
typedef struct _fastd_task_any {
- fastd_task_type type;
- fastd_peer *peer;
} fastd_task_any;
typedef struct _fastd_task_send {
- fastd_task_type type;
- fastd_peer *peer;
fastd_packet_type packet_type;
fastd_buffer buffer;
} fastd_task_send;
typedef struct _fastd_task_handle_recv {
- fastd_task_type type;
- fastd_peer *peer;
- fastd_packet_type packet_type;
fastd_buffer buffer;
} fastd_task_handle_recv;
-typedef struct _fastd_task_handshake {
+typedef struct _fastd_task {
+ fastd_queue_entry entry;
+
fastd_task_type type;
fastd_peer *peer;
-} fastd_task_handshake;
-typedef union _fastd_task {
- fastd_task_any any;
- fastd_task_send send;
- fastd_task_handle_recv handle_recv;
- fastd_task_handshake handshake;
+ union {
+ fastd_task_send send;
+ fastd_task_handle_recv handle_recv;
+ };
} fastd_task;
-fastd_task* fastd_task_get(fastd_context *ctx);
static inline int fastd_task_timeout(fastd_context *ctx) {
return fastd_queue_timeout(ctx, &ctx->task_queue);
}
+
+fastd_task* fastd_task_get(fastd_context *ctx);
+
void fastd_task_put_send_handshake(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer);
void fastd_task_put_send(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer);