summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/threading/binding/_thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/asura-lib-utils/threading/binding/_thread.cpp')
-rw-r--r--source/libs/asura-lib-utils/threading/binding/_thread.cpp210
1 files changed, 0 insertions, 210 deletions
diff --git a/source/libs/asura-lib-utils/threading/binding/_thread.cpp b/source/libs/asura-lib-utils/threading/binding/_thread.cpp
deleted file mode 100644
index a5aff03..0000000
--- a/source/libs/asura-lib-utils/threading/binding/_thread.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-#include "../thread.h"
-
-using namespace std;
-
-namespace AsuraEngine
-{
- namespace Threading
- {
-
- LUAX_REGISTRY(Thread)
- {
- LUAX_REGISTER_METHODS(state,
- { "New", _New },
- { "AddTask", _AddTask },
- { "Start", _Start },
- { "Idle", _Idle },
- { "Pause", _Pause },
- { "Resume", _Resume },
- { "Stop", _Stop },
- { "Join", _Join },
- { "IsRunning", _IsRunning },
- { "IsPaused", _IsPaused },
- { "IsStopped", _IsStopped },
- { "IsCurrent", _IsCurrent },
- { "Sleep", _Sleep },
- { "Post", _Post },
- { "GetName", _GetName },
- { "GetType", _GetType },
- { "GetState", _GetState }
- );
- }
-
- LUAX_POSTPROCESS(Thread)
- {
- LUAX_REGISTER_ENUM(state, "EThreadType",
- { "DEFERRED", THREAD_TYPE_DEFERRED },
- { "IMMEDIATE", THREAD_TYPE_IMMEDIATE }
- );
- LUAX_REGISTER_ENUM(state, "EThreadState",
- { "READY", THREAD_STATE_IDLE },
- { "RUNNING", THREAD_STATE_RUNNING },
- { "PAUSED", THREAD_STATE_PAUSED },
- { "STOPPED", THREAD_STATE_STOPPED }
- );
- }
-
- // thread = Thread.New(thread_type, sleepTime, name)
- LUAX_IMPL_METHOD(Thread, _New)
- {
- LUAX_STATE(L);
-
- ThreadType type = (ThreadType)state.GetValue<int>(1, THREAD_TYPE_DEFERRED);
- uint sleepTime = state.GetValue<uint>(2,1);
- cc8* name = state.GetValue<cc8*>(3, "");
-
- Thread* thread = new Thread(state, type, sleepTime, name);
- thread->PushLuaxUserdata(state);
-
- return 1;
- }
-
- // thread:AddTask(task)
- LUAX_IMPL_METHOD(Thread, _AddTask)
- {
- LUAX_PREPARE(L, Thread);
-
- Task* task = state.GetUserdata<Task>(2);
- self->AddTask(task);
- self->LuaxRetain<Task>(state, task);
- return 0;
- }
-
- // successed = thread:Start(isDeamon, stackSize)
- LUAX_IMPL_METHOD(Thread, _Start)
- {
- LUAX_PREPARE(L, Thread);
-
- bool isDaemon = state.GetValue(2, true);
- uint stackSize = state.GetValue(3, 0);
-
- state.Push(self->Start(isDaemon, stackSize));
- return 1;
- }
-
- // thread:Idle()
- LUAX_IMPL_METHOD(Thread, _Idle)
- {
- LUAX_PREPARE(L, Thread);
- self->Idle();
- return 0;
- }
-
- // thread:Pause()
- LUAX_IMPL_METHOD(Thread, _Pause)
- {
- LUAX_PREPARE(L, Thread);
- self->Pause();
- return 0;
- }
-
- // thread:Resume()
- LUAX_IMPL_METHOD(Thread, _Resume)
- {
- LUAX_PREPARE(L, Thread);
- self->Resume();
- return 0;
- }
-
- // thread:Stop()
- LUAX_IMPL_METHOD(Thread, _Stop)
- {
- LUAX_PREPARE(L, Thread);
- self->Stop();
- return 0;
- }
-
- // thread:Join()
- LUAX_IMPL_METHOD(Thread, _Join)
- {
- LUAX_PREPARE(L, Thread);
- self->Join();
- return 0;
- }
-
- // thread:IsRunning()
- LUAX_IMPL_METHOD(Thread, _IsRunning)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->IsRunning());
- return 1;
- }
-
- // thread:IsPaused()
- LUAX_IMPL_METHOD(Thread, _IsPaused)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->IsPaused());
- return 1;
- }
-
- // thread:IsStopped()
- LUAX_IMPL_METHOD(Thread, _IsStopped)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->IsStopped());
- return 1;
- }
-
- // thread:IsCurrent()
- LUAX_IMPL_METHOD(Thread, _IsCurrent)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->IsCurrent());
- return 1;
- }
-
- // Thread.Sleep(ms)
- LUAX_IMPL_METHOD(Thread, _Sleep)
- {
- LUAX_STATE(L);
- uint ms = state.GetValue(1, 0);
-#ifdef _WIN32
- ::Sleep(ms);
-#endif
- return 0;
- }
-
- // thread:Post()
- LUAX_IMPL_METHOD(Thread, _Post)
- {
- LUAX_PREPARE(L, Thread);
- self->Post();
- return 0;
- }
-
- // thread:GetName()
- LUAX_IMPL_METHOD(Thread, _GetName)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->GetName());
- return 1;
- }
-
- // thread:GetType()
- LUAX_IMPL_METHOD(Thread, _GetType)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->mType);
- return 1;
- }
-
- // thread:GetState()
- LUAX_IMPL_METHOD(Thread, _GetState)
- {
- LUAX_PREPARE(L, Thread);
- state.Push(self->mState);
- return 1;
- }
-
- // thread:SetSleepTime(sleepTime)
- LUAX_IMPL_METHOD(Thread, _SetSleepTime)
- {
- LUAX_PREPARE(L, Thread);
- uint time = state.CheckValue<uint>(2);
- self->SetSleepTime(time);
- return 0;
- }
-
- }
-}