1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*  Monkey HTTP Server (Duda I/O)
4  *  -----------------------------
5  *  Copyright 2017 Eduardo Silva <eduardo@monkey.io>
6  *  Copyright 2014, Zeying Xie <swpdtz at gmail dot com>
7  *
8  *  Licensed under the Apache License, Version 2.0 (the "License");
9  *  you may not use this file except in compliance with the License.
10  *  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *  Unless required by applicable law or agreed to in writing, software
15  *  distributed under the License is distributed on an "AS IS" BASIS,
16  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *  See the License for the specific language governing permissions and
18  *  limitations under the License.
19  */
20 
21 #ifndef MK_THREAD_H
22 #define MK_THREAD_H
23 
24 #include <mk_core/mk_pthread.h>
25 #include "mk_thread_channel.h"
26 
27 #define MK_THREAD_DEAD       0
28 #define MK_THREAD_READY      1
29 #define MK_THREAD_RUNNING    2
30 #define MK_THREAD_SUSPEND    3
31 
32 pthread_key_t mk_thread_scheduler;
33 
34 typedef void (*mk_thread_func)(void *data);
35 
36 struct mk_thread_scheduler *mk_thread_open();
37 void mk_thread_close(struct mk_thread_scheduler *sch);
38 
39 int mk_thread_create(mk_thread_func func, void *data);
40 int mk_thread_status(int id);
41 void mk_thread_yield();
42 void mk_thread_resume(int id);
43 int mk_thread_running();
44 
45 void mk_thread_add_channel(int id, struct mk_thread_channel *chan);
46 
47 #endif
48