- separate cleanly between async scheduling and file IO related issues.
[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                *overlapped;
34     unsigned int         status;
35     struct timeval       when;
36     struct timeout_user *timeout;
37     struct async        *next,*prev;
38     struct async_queue  *q;
39 };
40
41 struct async_queue
42 {
43     struct async        *head;
44     struct async        *tail;
45 };
46
47 void destroy_async( struct async *async );
48 void destroy_async_queue( struct async_queue *q );
49 void async_notify(struct async *async, int status);
50 struct async *find_async(struct async_queue *q, struct thread *thread, void *overlapped);
51 void async_insert(struct async_queue *q, struct async *async);
52 struct async *create_async(struct object *obj, struct thread *thread, 
53                            void *overlapped);
54 void async_add_timeout(struct async *async, int timeout);
55 static inline void init_async_queue(struct async_queue *q) 
56
57     q->head = q->tail = NULL;
58 }
59
60 #define IS_READY(q) (((q).head) && ((q).head->status==STATUS_PENDING))
61
62 #endif /* _SERVER_ASYNC_ */
63