diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 23:06:18 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 23:06:18 +0100 |
commit | f8a2fec8f399229d15d3481be0ce8567b2ed6851 (patch) | |
tree | c214fcb30a99791dabe3076ea8c449b3d6538c89 /src/task.h | |
parent | 1d18f972554c8bad0f08b3ff6727c87586e97094 (diff) | |
download | fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.tar fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.zip |
Simplify queue functions
Diffstat (limited to 'src/task.h')
-rw-r--r-- | src/task.h | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -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); |