aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/thread/je_lua_thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/modules/thread/je_lua_thread.h')
-rw-r--r--src/lua/modules/thread/je_lua_thread.h161
1 files changed, 79 insertions, 82 deletions
diff --git a/src/lua/modules/thread/je_lua_thread.h b/src/lua/modules/thread/je_lua_thread.h
index de9a8a8..ffe99d0 100644
--- a/src/lua/modules/thread/je_lua_thread.h
+++ b/src/lua/modules/thread/je_lua_thread.h
@@ -5,90 +5,87 @@ namespace JinEngine
{
namespace Lua
{
- namespace thread
+
+ class Thread
{
+ public:
+ typedef JinEngine::MultiThread::Thread::Variant Variant;
+ typedef JinEngine::MultiThread::Thread::ThreadRunner ThreadRunner;
+
+ Thread(std::string _name, std::string _code, ThreadRunner runner)
+ : name(_name)
+ , code(_code)
+ {
+ thread = new JinEngine::MultiThread::Thread(_name, runner);
+ }
+
+ ~Thread()
+ {
+ delete thread;
+ }
+
+ bool start(void* p)
+ {
+ return thread->start(p);
+ }
+
+ void wait()
+ {
+ thread->wait();
+ }
+
+ void send(int slot, const Variant& value)
+ {
+ thread->send(slot, value);
+ }
+
+ bool receive(int slot)
+ {
+ return thread->receive(slot);
+ }
+
+ Variant fetch(int slot)
+ {
+ return thread->fetch(slot);
+ }
- class Thread
+ Variant demand(int slot)
{
- public:
- typedef JinEngine::MultiThread::Thread::Variant Variant;
- typedef JinEngine::MultiThread::Thread::ThreadRunner ThreadRunner;
-
- Thread(std::string _name, std::string _code, ThreadRunner runner)
- : name(_name)
- , code(_code)
- {
- thread = new JinEngine::MultiThread::Thread(_name, runner);
- }
-
- ~Thread()
- {
- delete thread;
- }
-
- bool start(void* p)
- {
- return thread->start(p);
- }
-
- void wait()
- {
- thread->wait();
- }
-
- void send(int slot, const Variant& value)
- {
- thread->send(slot, value);
- }
-
- bool receive(int slot)
- {
- return thread->receive(slot);
- }
-
- Variant fetch(int slot)
- {
- return thread->fetch(slot);
- }
-
- Variant demand(int slot)
- {
- return thread->demand(slot);
- }
-
- void remove(int slot)
- {
- thread->remove(slot);
- }
-
- const char* getName()
- {
- return name.c_str();
- }
-
- bool isRunning()
- {
- return thread->isRunning();
- }
-
- void lock()
- {
- thread->lock();
- }
-
- void unlock()
- {
- thread->unlock();
- }
-
- const std::string name;
- const std::string code;
-
- private:
- JinEngine::MultiThread::Thread* thread;
-
- };
-
- } // thread
+ return thread->demand(slot);
+ }
+
+ void remove(int slot)
+ {
+ thread->remove(slot);
+ }
+
+ const char* getName()
+ {
+ return name.c_str();
+ }
+
+ bool isRunning()
+ {
+ return thread->isRunning();
+ }
+
+ void lock()
+ {
+ thread->lock();
+ }
+
+ void unlock()
+ {
+ thread->unlock();
+ }
+
+ const std::string name;
+ const std::string code;
+
+ private:
+ JinEngine::MultiThread::Thread* thread;
+
+ };
+
} // namespace Lua
} // namespace JinEngine \ No newline at end of file