Send message for WSAAsyncSelect sockets directly from the server,
[wine] / server / async.h
1 /*
2  * Async i/o definitions
3  *
4  * Copyright (C) 2000 Mike McCormack
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef _SERVER_ASYNC_
22 #define _SERVER_ASYNC_
23
24 #include <sys/time.h>
25 #include "object.h"
26
27 struct async_queue;
28
29 struct async 
30 {
31     struct object       *obj;
32     struct thread       *thread;
33     void                *func;
34     void                *overlapped;
35     unsigned int         status;
36     struct timeval       when;
37     struct timeout_user *timeout;
38     struct async        *next,*prev;
39     struct async_queue  *q;
40 };
41
42 struct async_queue
43 {
44     struct async        *head;
45     struct async        *tail;
46 };
47
48 void destroy_async( struct async *async );
49 void destroy_async_queue( struct async_queue *q );
50 void async_notify(struct async *async, int status);
51 struct async *find_async(struct async_queue *q, struct thread *thread, void *overlapped);
52 void async_insert(struct async_queue *q, struct async *async);
53 struct async *create_async(struct object *obj, struct thread *thread, 
54                            void *func, void *overlapped);
55 void async_add_timeout(struct async *async, int timeout);
56 static inline void init_async_queue(struct async_queue *q) 
57
58     q->head = q->tail = NULL;
59 }
60
61 #define IS_READY(q) (((q).head) && ((q).head->status==STATUS_PENDING))
62
63 #endif /* _SERVER_ASYNC_ */
64