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
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
#include "coroutine.h"
|
2015-03-21 11:47:51 +00:00
|
|
|
#include "coio.h"
|
|
|
|
|
|
|
|
typedef struct CoioTaskList CoioTaskList;
|
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
struct CoioTask
|
|
|
|
{
|
|
|
|
coroutine_context ctx;
|
2015-03-21 11:47:51 +00:00
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
coio_func func;
|
|
|
|
void* arg;
|
2015-03-21 11:47:51 +00:00
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
uvlong timeout;
|
|
|
|
int ready;
|
2015-03-21 11:47:51 +00:00
|
|
|
|
|
|
|
/* linked list support */
|
2015-08-25 19:17:41 +00:00
|
|
|
CoioTask* next;
|
|
|
|
CoioTask* prev;
|
2015-03-21 11:47:51 +00:00
|
|
|
};
|
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
struct CoioTaskList
|
|
|
|
{
|
|
|
|
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;
|
2015-08-25 19:17:41 +00:00
|
|
|
extern CoioTask* coio_current;
|
2015-03-28 15:02:10 +00:00
|
|
|
|
2015-08-25 19:17:41 +00:00
|
|
|
void coio_add(CoioTaskList* lst, CoioTask* task);
|
|
|
|
void coio_del(CoioTaskList* lst, CoioTask* task);
|
|
|
|
void coio_rdy(CoioTask* task);
|
|
|
|
void coio_transfer();
|
2015-03-21 11:47:51 +00:00
|
|
|
|
|
|
|
#endif
|