diff options
author | chai <chaifix@163.com> | 2018-08-06 13:12:35 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-06 13:12:35 +0800 |
commit | b17dc97d5aafe741e4139a82456dc04d7cf47dde (patch) | |
tree | 9c0f86c2ca7fda0dadd9cb094b48a1ff7ba851b3 /test | |
parent | bd848890aa59da667feede96910105c3adab349e (diff) |
*update
Diffstat (limited to 'test')
-rw-r--r-- | test/03Thread/threadtest.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/test/03Thread/threadtest.cpp b/test/03Thread/threadtest.cpp index d5d75e4..5d03893 100644 --- a/test/03Thread/threadtest.cpp +++ b/test/03Thread/threadtest.cpp @@ -1,4 +1,5 @@ #include <iostream> +#include <functional> #include "jin.h" using namespace std; @@ -30,22 +31,29 @@ void onDraw() int thread2Runner(void* p) { - char* s = (char*)p; + Thread* t = (Thread*)p; int i = 0; while (true) { if (i++ == 1000000000) { i = 0; - cout << s; + cout << (char*)(t->demand("test").pointer); } } return 0; } -int thread3Runner(void* p) +Thread t("Thread 2", thread2Runner); + +void sendFunc(void* p) { + t.send("test", (void*)"hello_"); +} +int thread3Runner(void* p) +{ + return 1; } int main(int argc, char* argv[]) @@ -69,13 +77,8 @@ int main(int argc, char* argv[]) wndSetting.resizable = false; wnd->init(&wndSetting); - timers.every(1000, [](void* p)-> void{ - cout << 1; - }, nullptr); - - Thread t("Thread 2", thread2Runner); - char* str = "_OK"; - t.start(str); + t.start(); + timers.after(2000, sendFunc, nullptr); game->run(); |