Yume Project 3.0
Touhou-inspired Danmaku game made in C only
Chargement...
Recherche...
Aucune correspondance
cotask.h
Aller à la documentation de ce fichier.
1#pragma once
2
3#include <stdint.h>
4#include <stdlib.h>
5
6#include "ecs.h"
7#include "../include/koishi.h"
8#include "list.h"
9#include "common.h"
10
11typedef struct CoTask CoTask;
12typedef LIST_ANCHOR(CoTask) CoTaskList;
13typedef void *(*CoTaskFunc)(void *arg, size_t argsize);
14
15typedef enum CoStatus{
16 CO_STATUS_SUSPENDED = KOISHI_SUSPENDED,
17 CO_STATUS_RUNNING = KOISHI_RUNNING,
18 CO_STATUS_IDLE = KOISHI_IDLE,
19 CO_STATUS_DEAD = KOISHI_DEAD
21
25typedef struct BoxedTask {
26 uintptr_t ptr; // pointeur vers la task
27 uint32_t unique_id; // sécurité
29
30#include "coevent.h"
31
32// Pour les wait
37
38typedef struct CoSched CoSched;
39
40/*----------------------------------*/
41/* Fonctions */
42/*----------------------------------*/
43
45
53
64
70void cotask_cancel(CoTask *task);
71
79
86
94void *cotask_resume(CoTask *task, void *arg);
95
102void *cotask_yield(void *arg);
103
110int cotask_wait(int delay);
111
118
126
134
142
150
159
166CoTaskEvents *cotask_get_events(CoTask *task);
167
168
170void cotask_host_events(CoTask *task, unsigned int num_events, CoEvent events[num_events]);
171
172void cotask_free(CoTask *task);
173
CoEventStatus
Definition coevent.h:6
Composants communs à toutes les entités (Position, Tag).
EntityType Tag
Definition common.h:40
CoWaitResult cotask_wait_event_once(CoEvent *evt)
Wait un événement une seule fois.
CoSched * cotask_get_sched(CoTask *task)
Renvoie le scheduler d'une tache.
void * cotask_resume(CoTask *task, void *arg)
Redonne la main a la task.
CoTask * cotask_active(void)
Renvoie la cotask actuellement en train de run.
int cotask_wait_subtasks(void)
Wait les soustaches actives.
Entity cotask_host_entity(CoTask *task, Tag ent_type)
void cotask_cancel(CoTask *task)
Annule une tache.
CoWaitResult cotask_wait_event_or_die(CoEvent *evt)
Wait un événement, sinon cancel la tache.
int cotask_wait(int delay)
Permet de yield pdt delay frames.
CoStatus cotask_status(CoTask *task)
Renvoie le statut de la task.
Entity cotask_bind_to_entity(CoTask *task, Entity ent)
Rattache une tache a une entité
CoTask * cotask_unbox(BoxedTask box)
A partir d'une boite, retrouver la task correspondante.
BoxedTask cotask_box(CoTask *task)
Emballer une task dans une boite (ref faible).
void cotask_force_finish(CoTask *task)
CoStatus
Definition cotask.h:15
@ CO_STATUS_SUSPENDED
Definition cotask.h:16
@ CO_STATUS_RUNNING
Definition cotask.h:17
@ CO_STATUS_DEAD
Definition cotask.h:19
@ CO_STATUS_IDLE
Definition cotask.h:18
void * cotask_yield(void *arg)
Yield la coroutine active (redonne la main au main).
CoTaskEvents * cotask_get_events(CoTask *task)
Renvoie les événements d'une tache.
void cotask_host_events(CoTask *task, unsigned int num_events, CoEvent events[num_events])
CoWaitResult cotask_wait_event(CoEvent *evt)
Wait un événement.
void cotask_free(CoTask *task)
Types et déclarations utilisés dans l'ECS.
uint32_t Entity
Une entité est un indice.
Definition ecs.h:20
#define LIST_ANCHOR(type)
Definition list.h:38
Une BoxedTask est une référence faible a une task.
Definition cotask.h:25
uint32_t unique_id
Definition cotask.h:27
uintptr_t ptr
Definition cotask.h:26
Definition coevent.h:14
Definition cosched.h:8
Definition cotask_data.h:24
Definition cotask.h:33
int frames
Definition cotask.h:34
CoEventStatus event_status
Definition cotask.h:35