2015-03-25 21:02:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Moritz Bitsch <moritzbitsch@gmail.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2015-03-21 11:47:51 +00:00
|
|
|
#ifndef COIOIMPL_H
|
2015-03-28 15:02:10 +00:00
|
|
|
#define COIOIMPL_H
|
2015-03-21 11:47:51 +00:00
|
|
|
|
|
|
|
#include "coro.h"
|
|
|
|
#include "coio.h"
|
|
|
|
|
|
|
|
typedef struct CoioTaskList CoioTaskList;
|
|
|
|
|
|
|
|
struct CoioTask {
|
2015-03-25 20:16:49 +00:00
|
|
|
coro_context ctx;
|
2015-03-21 11:47:51 +00:00
|
|
|
struct coro_stack stk;
|
|
|
|
|
2015-03-25 20:16:49 +00:00
|
|
|
coio_func func;
|
|
|
|
void *arg;
|
2015-03-21 11:47:51 +00:00
|
|
|
|
2015-03-28 15:02:10 +00:00
|
|
|
uvlong timeout;
|
2015-03-25 20:16:49 +00:00
|
|
|
int done;
|
2015-03-21 11:47:51 +00:00
|
|
|
|
|
|
|
/* linked list support */
|
2015-03-25 20:16:49 +00:00
|
|
|
CoioTask *next;
|
|
|
|
CoioTask *prev;
|
2015-03-21 11:47:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CoioTaskList {
|
2015-03-25 20:16:49 +00:00
|
|
|
CoioTask *head;
|
|
|
|
CoioTask *tail;
|
2015-03-21 11:47:51 +00:00
|
|
|
};
|
|
|
|
|
2015-03-28 15:02:10 +00:00
|
|
|
extern CoioTaskList coio_ready;
|
|
|
|
extern CoioTaskList coio_sleeping;
|
|
|
|
extern CoioTask *coio_current;
|
2018-07-27 06:49:34 +00:00
|
|
|
extern coro_context coio_sched_ctx;
|
|
|
|
extern unsigned long coio_taskcount;
|
2015-03-28 15:02:10 +00:00
|
|
|
|
2015-03-25 20:16:49 +00:00
|
|
|
void coio_add (CoioTaskList * lst, CoioTask * task);
|
|
|
|
void coio_del (CoioTaskList * lst, CoioTask * task);
|
2015-03-28 15:02:10 +00:00
|
|
|
void coio_rdy (CoioTask * task);
|
|
|
|
void coio_transfer();
|
2015-03-21 11:47:51 +00:00
|
|
|
|
|
|
|
#endif
|