From 80377b3705add893a58b5cb2d0ee296704438f8d Mon Sep 17 00:00:00 2001 From: hackerchai Date: Thu, 19 Sep 2024 18:44:38 +0800 Subject: [PATCH] feat(c/libuv): Implement thread related funcs Signed-off-by: hackerchai --- c/libuv/thread.go | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 c/libuv/thread.go diff --git a/c/libuv/thread.go b/c/libuv/thread.go new file mode 100644 index 00000000..ee36a07e --- /dev/null +++ b/c/libuv/thread.go @@ -0,0 +1,80 @@ +package libuv + +import ( + _ "unsafe" + + "github.com/goplus/llgo/c" +) + +type Thread struct { + Unused [8]byte +} + +type ThreadOptions struct { + flags c.Uint + stackSize uintptr +} + +type Work struct { + Unused [128]byte +} + +// ---------------------------------------------- + +/* Function type */ + +// llgo:type C +type ThreadCb func(arg c.Pointer) + +//llgo:type C +type WorkCb func(req *Work) + +//llgo:type C +type AfterWorkCb func(req *Work, status c.Int) + +// ---------------------------------------------- + +/* Thread related functions and method. */ + +//go:linkname ThreadEqual C.uv_thread_equal +func ThreadEqual(t1 *Thread, t2 *Thread) c.Int + +//go:linkname ThreadGetCPU C.uv_thread_getcpu +func ThreadGetCPU() c.Int + +//go:linkname ThreadSelf C.uv_thread_self +func ThreadSelf() Thread + +// llgo:link (*Thread).Create C.uv_thread_create +func (t *Thread) Create(entry ThreadCb, arg c.Pointer) c.Int { + return 0 +} + +// llgo:link (*Thread).CreateEx C.uv_thread_create_ex +func (t *Thread) CreateEx(entry ThreadCb, params *ThreadOptions, arg c.Pointer) c.Int { + return 0 +} + +// llgo:link (*Thread).Join C.uv_thread_join +func (t *Thread) Join() c.Int { + return 0 +} + +// llgo:link (*Thread).SetAffinity C.uv_thread_set_affinity +func (t *Thread) SetAffinity(cpuMask *c.Char, oldMask *c.Char, maskSize uintptr) c.Int { + return 0 +} + +// llgo:link (*Thread).GetAffinity C.uv_thread_get_affinity +func (t *Thread) GetAffinity(cpuMask *c.Char, maskSize uintptr) c.Int { + return 0 +} + +// ---------------------------------------------- + +/* Work related functions and method. */ + +//go:linkname QueueWork C.uv_queue_work +func QueueWork(loop *Loop, req *Work, workCb WorkCb, afterWorkCb AfterWorkCb) c.Int + +