diff options
author | chai <chaifix@163.com> | 2018-08-07 12:56:28 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-07 12:56:28 +0800 |
commit | 35d0affb2b19a38ae43ac991021dd3c888dc3aa6 (patch) | |
tree | 378e1a6bf6fec56568dcec6aac15c4426f1f9375 /test/03Thread/threadtest.cpp | |
parent | df24addf48a6de2c4ef4e1723ae7d9c1d261dabe (diff) |
*update
Diffstat (limited to 'test/03Thread/threadtest.cpp')
-rw-r--r-- | test/03Thread/threadtest.cpp | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/test/03Thread/threadtest.cpp b/test/03Thread/threadtest.cpp deleted file mode 100644 index a792e53..0000000 --- a/test/03Thread/threadtest.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include <iostream> -#include <functional> -#include "jin.h" - -using namespace std; -using namespace jin::core; -using namespace jin::graphics; -using namespace jin::input; -using namespace jin::audio; -using namespace jin::time; -using namespace jin::thread; - -Timers timers; - -void onEvent(jin::input::Event* e) -{ - static Game* game = Game::get(); - if (e->type == EventType::QUIT) - game->stop(); -} - -void onUpdate(int ms) -{ - timers.update(ms); -} - -void onDraw() -{ - -} - -void thread2Runner(Thread* t) -{ - int i = 0; - while (true) - { - if (i++ == 1000000000) - { - i = 0; - cout << (char*)(t->demand(1).pointer); - } - } -} - -void sendFunc(void* p) -{ - Thread* t = (Thread*)p; - t->send(1, "hello_"); -} - -int main(int argc, char* argv[]) -{ - Game* game = Game::get(); - Game::Setting setting; - setting.eventHandler = onEvent; - setting.updater = onUpdate; - setting.drawer = onDraw; - setting.loader = nullptr; - game->init(&setting); - - Window* wnd = Window::get(); - Window::Setting wndSetting; - wndSetting.width = 600; - wndSetting.height = 512; - wndSetting.title = "test"; - wndSetting.fps = 60; - wndSetting.vsync = false; - wndSetting.fullscreen = false; - wndSetting.resizable = false; - wnd->init(&wndSetting); - - Thread t("Count", thread2Runner); - - t.start(); - timers.after(2000, sendFunc, &t); - - game->run(); - - game->quit(); - wnd->quit(); - - return 0; -}
\ No newline at end of file |