hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
threading.h
Go to the documentation of this file.
1//
2// Created by XIaokang00010 on 2025/9/12.
3//
4
5#ifndef HOSHI_LANG_THREADING_H
6#define HOSHI_LANG_THREADING_H
7
9#include <cstdint>
10
11#ifdef _WIN32
12#include <windows.h>
13#include <process.h>
14typedef HANDLE YoiThreadHandle;
15typedef DWORD YoiThreadId;
16#else
17#include <pthread.h>
18#include <signal.h>
19typedef pthread_t YoiThreadHandle;
20typedef pthread_t YoiThreadId;
21#endif
22
24 unsigned long long gc_refcount;
25 unsigned long long type_id;
26 void *this_ptr;
27 void *(*gc_inc_func)(void *this_ptr);
28 void *(*gc_dec_func)(void *this_ptr);
29 void *(*callable)(void *this_ptr);
30};
31
38
40
42
43extern "C" uint64_t runtime_get_thread_id();
44
45extern "C" uint64_t runtime_thread_hardware_concurrency();
46
48
50
52
53extern "C" void runtime_thread_mutex_lock(YoiUnsignedObject *mutex_handle);
54
55extern "C" void runtime_thread_mutex_unlock(YoiUnsignedObject *mutex_handle);
56
58
60
61extern "C" void runtime_thread_condition_wait(YoiUnsignedObject *condition_handle, YoiUnsignedObject *mutex_handle);
62
63extern "C" void runtime_thread_condition_signal(YoiUnsignedObject *condition_handle);
64
66
67#endif //HOSHI_LANG_THREADING_H
unsigned long long gc_refcount
Definition threading.h:33
unsigned long long type_id
Definition threading.h:34
YoiUnsignedObject * ok
Definition threading.h:35
YoiIntegerObject * err
Definition threading.h:36
unsigned long long gc_refcount
Definition threading.h:24
unsigned long long type_id
Definition threading.h:25
pthread_t YoiThreadId
Definition threading.h:20
void runtime_thread_mutex_lock(YoiUnsignedObject *mutex_handle)
void runtime_thread_condition_wait(YoiUnsignedObject *condition_handle, YoiUnsignedObject *mutex_handle)
YoiIntegerObject * runtime_ping_thread(YoiUnsignedObject *thread_id_obj)
YoiResultUnsignedAndIntObject * runtime_start_thread(YoiVoidCallableInterface *callable)
void runtime_thread_mutex_unlock(YoiUnsignedObject *mutex_handle)
YoiResultUnsignedAndIntObject * runtime_thread_new_condition()
void runtime_thread_finalize_mutex_lock(YoiUnsignedObject *handle)
YoiIntegerObject * runtime_thread_join(YoiUnsignedObject *thread_handle)
YoiResultUnsignedAndIntObject * runtime_thread_new_mutex_lock()
uint64_t runtime_get_thread_id()
pthread_t YoiThreadHandle
Definition threading.h:19
uint64_t runtime_thread_hardware_concurrency()
void runtime_thread_condition_signal(YoiUnsignedObject *condition_handle)
YoiIntegerObject * runtime_thread_mutex_try_lock(YoiUnsignedObject *mutex_handle)
void runtime_thread_finalize_condition(YoiUnsignedObject *handle)