factor/native/io.h

53 lines
1.2 KiB
C
Raw Normal View History

2004-08-13 02:19:22 -04:00
typedef enum {
IO_TASK_READ_LINE,
IO_TASK_READ_COUNT,
IO_TASK_WRITE,
IO_TASK_ACCEPT
2004-08-13 02:19:22 -04:00
} IO_TASK_TYPE;
2004-08-13 01:38:15 -04:00
typedef struct {
2004-08-13 02:19:22 -04:00
IO_TASK_TYPE type;
CELL port;
2004-08-23 20:44:58 -04:00
/* TAGGED list of callbacks, or F */
/* Multiple callbacks per port are only permitted for IO_TASK_WRITE. */
CELL callbacks;
2004-08-13 01:38:15 -04:00
} IO_TASK;
2004-08-13 01:38:15 -04:00
fd_set read_fd_set;
IO_TASK read_io_tasks[FD_SETSIZE];
int read_fd_count;
fd_set write_fd_set;
IO_TASK write_io_tasks[FD_SETSIZE];
int write_fd_count;
2004-08-19 02:29:14 -04:00
fd_set except_fd_set;
2004-08-13 01:38:15 -04:00
void init_io_tasks(fd_set* fd_set, IO_TASK* io_tasks);
2004-08-20 01:49:14 -04:00
void init_io(void);
2004-08-15 21:50:44 -04:00
IO_TASK* add_io_task(
2004-08-13 02:19:22 -04:00
IO_TASK_TYPE type,
2004-08-13 01:38:15 -04:00
PORT* port,
CELL callback,
IO_TASK* io_tasks,
int* fd_count);
void primitive_add_accept_io_task(void);
2004-08-15 21:50:44 -04:00
void remove_io_task(
2004-08-13 02:19:22 -04:00
IO_TASK_TYPE type,
2004-08-13 01:38:15 -04:00
PORT* port,
IO_TASK* io_tasks,
int* fd_count);
2004-08-15 21:50:44 -04:00
void remove_io_tasks(PORT* port);
2004-08-23 20:44:58 -04:00
CELL pop_io_task_callback(
IO_TASK_TYPE type,
PORT* port,
IO_TASK* io_tasks,
int* fd_count);
2004-08-15 21:50:44 -04:00
bool set_up_fd_set(fd_set* fdset, int fd_count, IO_TASK* io_tasks);
2004-08-23 20:44:58 -04:00
CELL perform_io_task(IO_TASK* io_task, IO_TASK* io_tasks, int* fd_count);
CELL perform_io_tasks(fd_set* fdset, IO_TASK* io_tasks, int* fd_count);
2004-08-15 21:50:44 -04:00
CELL next_io_task(void);
void primitive_next_io_task(void);
2004-08-20 01:49:14 -04:00
void primitive_close(void);
2004-08-13 02:19:22 -04:00
void collect_io_tasks(void);