From 9acf2e925b1080e4dbcc5ad1b862c991040775b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Wed, 1 Apr 2015 00:54:13 +0000 Subject: [PATCH] lol Buildfix --- doc/samples/data/meshviewer_buffer.lua | 103 ------------------------- doc/samples/meshviewer/meshviewer.cpp | 5 +- doc/samples/meshviewer/scenesetup.h | 2 +- src/input/controller.h | 2 +- src/lol/sys/all.h | 2 +- src/lol/sys/thread.h | 5 +- src/lol/sys/threadtypes.h | 1 + src/sys/thread.cpp | 25 +++--- src/sys/threadbase.h | 33 -------- 9 files changed, 23 insertions(+), 155 deletions(-) delete mode 100644 doc/samples/data/meshviewer_buffer.lua diff --git a/doc/samples/data/meshviewer_buffer.lua b/doc/samples/data/meshviewer_buffer.lua deleted file mode 100644 index aa9daacc..00000000 --- a/doc/samples/data/meshviewer_buffer.lua +++ /dev/null @@ -1,103 +0,0 @@ - -//SCENE SETUP END - -//addlight 0.0 position (1 0 1) color #0ff -//addlight 0.0 position (-0.2 -1 -0.5) color (.0 .2 .5 1) - -//custom setmesh "sc#f00 ab 2 ty 1.5 ab 2" - -custom setmesh " - -//tqw -//CMD TEST -//sc#0f0 asph 1 10 -//sc#0f0 ab 10 -//sc#0f0 afcb 1 -.2 -//sc#0f0 acg 8 1 1 1 2 2 1.5 1.5 -.4 -//sc#0f0 as 6 1 2 -//sc#0f0 scb#f00 aes 6 1 2 2 -//sc#0f0 ac 6 5 2 2 false true true -//sc#0f0 aq 1 -//splt 2 smth 4 0 1 - -//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup [ rz 90 ry 90 scv#00f dup [ ry 90 scv#f00 ] ] ] -//[sc#fff ab .1] - -//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1] - -//[sc#fff ab 1 tx .5 ty .5] -//[sc#fff ab 1 tx -.5 ty -.5] - - -//[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1] - -//smth 3 1 1 smth 8 0 1 -//[sc#fff loop 4 [ [loop 4 [ab 1 tx 2]] tz 2]] - - -//[sc#f00 scb#f00 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rz -90] -//[sc#00f scb#00f ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rx 90] -//[sc#f00 ab .2 tx 1] -//[sc#0f0 ab .2 ty 1] -//[sc#00f ab .2 tz 1] -//sc#0f0 ab 2 ty 1.5 ab 2 -//sc#00f ab 2 ty 1.5 ab 2 - -//sc#00f tqw lp 5[tz 11 [lp 6 [tx 5 ty 5 afcb 10 -1 ]]] tz -22 - -// tqw -sc#f00 ab 10 -//tz 5 -//vm -// splt 1 -// rj .2 -// splt 1 -// rj .2 -// smth 1 0 1 - -//[sc#66f afcb(10) .25tx0]csgs[sc#fff afcb(10).25t(2)][[sc#6f6 afcb(7).25]csgs[sc#fff afcb(7).25t(1.5)]][[sc#f44 asph4 12t(-2.5)]csga[sc#fff afcb(7).25t(1.4)]csgs[sc#fff afcb(7).25t(2.5)]][[sc#ff0 ato6 2.5 1.2rx90tz-1.25tx-.9][sc#ff0 ab.5 2.1 .5dup[rz90sx.5ty-.8tx-.28]ty.55tx.25tz-.4taz1 1sy.8sx.8ty-.55tx-.25tz.4tz-1.2tx1.2]tz1.25tx1.25dup[sx-1ry90]tz-1.25tx-1.25] - -" - -//splt 0 -//test -//[sc#f8f ab 1 splt 4 twy 90] - - -// splt 5 twy 90 0 -//[sc#f8f afcb 10 10 10 .25 tx 0 splt 4 twy 1.6 0 ] -//sc#fff -//[afcb 1 1 1 -.1 tx 1] -//[afcb 1 1 1 -.1 tx 0] -//[afcb 1 1 1 -.1 tx -1] -//[[afcb 1 1 1 -.1 tx 1] -//[afcb 1 1 1 -.1 tx 0] -//[afcb 1 1 1 -.1 tx -1]tz 1] -//[[afcb 1 1 1 -.1 tx 1] -//[afcb 1 1 1 -.1 tx 0] -//[afcb 1 1 1 -.1 tx -1]tz -1] -//[afcb 3 .2 3 -.05 ty -.6] - - -//[sc#fff scb#fff ato 20 8 12 rx0] -//[sc#fff scb#fff acg 8 2 5 1 6 8 4 2 .1 1] - -//[sc#fff ab 4 4 4 ]//twy 45 0 bdxy 90 0 splt 5 tz 2 -//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0] -//[sc#88f ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .125 stx 10 0 0] - // tax -2 0 0 0 -//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 shz 1 0 0 0] -//[sc#fff asph 4 4] -//[sc#ff2 asph 4 4 tax .4 .4 0] -//[sc#ff2 asph 2 4] -//[sc#fff acap 1 4 4] -//[sc#fff scb#fff ac 10 4 4 4 0 0 1] -//[sc#ff2 scb#ff2 ad 10 4 0] -//[sc#fff scb#fff at 4 1] -//[sc#fff scb#000 aq 4 1] -//[sc#fff scb#2ff aes 5 3 6 2] -//[sc#fff scb#2ff as 4 2 4 0 0] -//[sc#fff scb#fff acg 2 10 .1 .1 .4 .4 .1 .1 0 1] - -//[sc#ff2 asph 2 10 10 10] -//[sc#400 asph 2 10 10 10 t 2 2 2 csgs] diff --git a/doc/samples/meshviewer/meshviewer.cpp b/doc/samples/meshviewer/meshviewer.cpp index 37050588..91fb211f 100644 --- a/doc/samples/meshviewer/meshviewer.cpp +++ b/doc/samples/meshviewer/meshviewer.cpp @@ -147,7 +147,7 @@ void MeshViewer::Start() m_entities << (m_file_check = new FileUpdateTester()); m_file_status = m_file_check->RegisterFile(m_file_name); - m_entities << (m_file_loader = new DefaultThreadManager(1, 1)); + //m_entities << (m_file_loader = new DefaultThreadManager(1, 1)); //Camera setup m_camera = new Camera(); @@ -222,7 +222,7 @@ void MeshViewer::TickGame(float seconds) //Check file update ASSERT(m_file_status); - if (m_file_status->HasUpdated()) + if (false && m_file_status->HasUpdated()) { MeshViewerLoadJob* job = GetLoadJob(m_file_name); if (!job) @@ -230,6 +230,7 @@ void MeshViewer::TickGame(float seconds) } //Check work done + if (false) { array result; m_file_loader->GetWorkResult(result); diff --git a/doc/samples/meshviewer/scenesetup.h b/doc/samples/meshviewer/scenesetup.h index d5008579..53f55024 100644 --- a/doc/samples/meshviewer/scenesetup.h +++ b/doc/samples/meshviewer/scenesetup.h @@ -155,7 +155,7 @@ public: SceneSetupLuaLoader(); virtual ~SceneSetupLuaLoader(); //Virtual Store lua object ------------------------------------------------ - virtual void Store(LuaObject* obj) { } + virtual void Store(LuaObject* obj); array& GetInstances(); //------------------------------------------------------------------------- diff --git a/src/input/controller.h b/src/input/controller.h index 7c6cac93..36bde84f 100644 --- a/src/input/controller.h +++ b/src/input/controller.h @@ -240,7 +240,7 @@ public: bool IsEmpty() const { - return !(GetKeyCount() && GetAxisCount()); + return !GetKeyCount() && !GetAxisCount(); } int GetKeyCount() const { diff --git a/src/lol/sys/all.h b/src/lol/sys/all.h index cf492a35..9601cdac 100644 --- a/src/lol/sys/all.h +++ b/src/lol/sys/all.h @@ -10,9 +10,9 @@ #pragma once +#include #include #include #include #include -#include diff --git a/src/lol/sys/thread.h b/src/lol/sys/thread.h index 1769d35f..96c1cb4c 100644 --- a/src/lol/sys/thread.h +++ b/src/lol/sys/thread.h @@ -130,7 +130,7 @@ protected: void StopThreads(int nb); //Work stuff - bool AddWork(ThreadJob* job); + bool AddWork(ThreadJob* job, bool force = false); //Fetch Results bool FetchResult(array& results); @@ -145,10 +145,11 @@ protected: int m_thread_count; int m_thread_min; array m_threads; + array m_job_dispatch; +private: queue m_spawnqueue, m_donequeue; queue m_jobqueue; queue m_resultqueue; - array m_job_dispatch; }; } /* namespace lol */ diff --git a/src/lol/sys/threadtypes.h b/src/lol/sys/threadtypes.h index d29a714a..2b7f2357 100644 --- a/src/lol/sys/threadtypes.h +++ b/src/lol/sys/threadtypes.h @@ -50,6 +50,7 @@ class FileUpdateTester : public BaseThreadManager public: class Status { + friend class FileUpdateTester; protected: mutex m_mutex; long int m_time = 0; diff --git a/src/sys/thread.cpp b/src/sys/thread.cpp index 1c71f4c8..e8eb3de0 100644 --- a/src/sys/thread.cpp +++ b/src/sys/thread.cpp @@ -41,7 +41,7 @@ bool BaseThreadManager::Start() return false; //Add minimum threads - m_threads.Resize(m_thread_count); + m_threads.reserve(m_thread_count); AddThreads(m_thread_min); return true; @@ -91,11 +91,12 @@ void BaseThreadManager::StopThreads(int nb) } //Work stuff -bool BaseThreadManager::AddWork(ThreadJob* job) +bool BaseThreadManager::AddWork(ThreadJob* job, bool force) { - if (m_jobqueue.try_push(job)) - return true; - return false; + if (!force) + return m_jobqueue.try_push(job); + m_jobqueue.push(job); + return true; } //---- @@ -110,20 +111,20 @@ bool BaseThreadManager::FetchResult(array& results) //Base thread work function void BaseThreadManager::BaseThreadWork() { -#if !LOL_FEATURE_THREADS +#if LOL_FEATURE_THREADS //Register that the thread has started m_spawnqueue.push(ThreadStatus::THREAD_STARTED); for ( ; ; ) -#endif //!LOL_FEATURE_THREADS +#endif //LOL_FEATURE_THREADS { //Try to retrieve a job ThreadJob* job = m_jobqueue.pop(); //Stop thread if (job->GetJobType() == ThreadJobType::THREAD_STOP) { -#if !LOL_FEATURE_THREADS +#if LOL_FEATURE_THREADS break; -#endif //!LOL_FEATURE_THREADS +#endif //LOL_FEATURE_THREADS } //Or work else if (*job == ThreadJobType::WORK_TODO) @@ -135,10 +136,10 @@ void BaseThreadManager::BaseThreadWork() m_resultqueue.push(job); } } -#if !LOL_FEATURE_THREADS +#if LOL_FEATURE_THREADS //Register that the thread has stopped m_donequeue.push(ThreadStatus::THREAD_STOPPED); -#endif //!LOL_FEATURE_THREADS +#endif //LOL_FEATURE_THREADS } //---- @@ -150,7 +151,7 @@ void BaseThreadManager::TickGame(float seconds) Start(); //Dispatch work task - while (m_job_dispatch.Count() > 0 && AddWork(m_job_dispatch.Last())) + while (m_job_dispatch.count() > 0 && AddWork(m_job_dispatch.last())) m_job_dispatch.pop(); //Execute one task per frame if thread are not available diff --git a/src/sys/threadbase.h b/src/sys/threadbase.h index 62006a1d..90c77501 100644 --- a/src/sys/threadbase.h +++ b/src/sys/threadbase.h @@ -131,39 +131,6 @@ public: current_count = (ptrdiff_t)m_count; -#if defined HAVE_PTHREAD_H - /* If there were poppers waiting, signal the "empty" cond var. */ - if (m_poppers) - pthread_cond_signal(&m_empty_cond); - pthread_mutex_unlock(&m_mutex); -#elif defined _WIN32 - LeaveCriticalSection(&m_mutex); - ReleaseSemaphore(m_full_sem, 1, nullptr); -#endif - return current_count; - } - - ptrdiff_t try_count() - { - ptrdiff_t current_count = 0; - -#if defined HAVE_PTHREAD_H - pthread_mutex_lock(&m_mutex); - /* If queue is full, wait on the "full" cond var. */ - if (m_count == CAPACITY) - { - pthread_mutex_unlock(&m_mutex); - return false; - } -#elif defined _WIN32 - DWORD status = WaitForSingleObject(m_empty_sem, 0); - if (status == WAIT_TIMEOUT) - return 0; - EnterCriticalSection(&m_mutex); -#endif - - current_count = (ptrdiff_t)m_count; - #if defined HAVE_PTHREAD_H /* If there were poppers waiting, signal the "empty" cond var. */ if (m_poppers)