open-isns: Fix warnings reported by gcc-4.5.2
[open-iscsi.git] / usr / actor.h
blob704224dda1e4dda0168e40a68da28833e6f8de68
1 /*
2 * iSCSI usermode single-threaded scheduler
4 * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman
5 * maintained by open-iscsi@googlegroups.com
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * See the file COPYING included with this distribution for more details.
19 #ifndef ACTOR_H
20 #define ACTOR_H
22 #include "types.h"
23 #include "list.h"
25 #define ACTOR_RESOLUTION 250 /* in millis */
26 #define ACTOR_MAX_LOOPS 1
28 typedef enum actor_state_e {
29 ACTOR_INVALID,
30 ACTOR_WAITING,
31 ACTOR_SCHEDULED,
32 ACTOR_NOTSCHEDULED,
33 ACTOR_POLL_WAITING
34 } actor_state_e;
36 typedef struct actor {
37 struct list_head list;
38 actor_state_e state;
39 void *data;
40 void (*callback)(void * );
41 uint64_t scheduled_at;
42 uint64_t ttschedule;
43 } actor_t;
45 extern void actor_new(actor_t *thread, void (*callback)(void *), void * data);
46 extern void actor_delete(actor_t *thread);
47 extern void actor_schedule_head(actor_t *thread);
48 extern void actor_schedule(actor_t *thread);
49 extern void actor_timer(actor_t *thread, uint32_t timeout,
50 void (*callback)(void *), void *data);
51 extern int actor_timer_mod(actor_t *thread, uint32_t new_timeout, void *data);
52 extern void actor_poll(void);
53 extern void actor_init(void);
55 #endif /* ACTOR_H */