diff --git a/bin/assets/linters/linters.json b/bin/assets/linters/linters.json index a17b1596c..04519a51a 100644 --- a/bin/assets/linters/linters.json +++ b/bin/assets/linters/linters.json @@ -27,5 +27,11 @@ "warning_pattern": "[^:]:(%d+):(%d+):%s?([^%s]*)([^\n]*)", "warning_pattern_order": { "line": 1, "col": 2, "message": 4, "type": 3 }, "command": "shellcheck -f gcc $FILENAME" + }, + { + "file_patterns": ["%.sol$"], + "warning_pattern": "(%d+):(%d+)%s.(%w*)%s.([^\n]*)", + "warning_pattern_order": { "line": 1, "col": 2, "message": 4, "type": 3 }, + "command": "solhint $FILENAME" } ] diff --git a/include/eepp/system/threadpool.hpp b/include/eepp/system/threadpool.hpp index e96353279..0c1870b6f 100644 --- a/include/eepp/system/threadpool.hpp +++ b/include/eepp/system/threadpool.hpp @@ -15,13 +15,15 @@ namespace EE { namespace System { class EE_API ThreadPool : NonCopyable { public: - static std::shared_ptr createShared( Uint32 numThreads ); + static std::shared_ptr createShared( Uint32 numThreads, + bool terminateOnClose = false ); - static std::unique_ptr createUnique( Uint32 numThreads ); + static std::unique_ptr createUnique( Uint32 numThreads, + bool terminateOnClose = false ); - static ThreadPool* createRaw( Uint32 numThreads ); + static ThreadPool* createRaw( Uint32 numThreads, bool terminateOnClose = false ); - ThreadPool( Uint32 numThreads ); + ThreadPool( Uint32 numThreads, bool terminateOnClose = false ); virtual ~ThreadPool(); @@ -29,6 +31,10 @@ class EE_API ThreadPool : NonCopyable { Uint32 numThreads() const; + bool terminateOnClose() const; + + void setTerminateOnClose( bool terminateOnClose ); + private: struct Work { const std::function func; @@ -40,6 +46,7 @@ class EE_API ThreadPool : NonCopyable { std::vector> mThreads; std::deque> mWork; bool mShuttingDown = false; + bool mTerminateOnClose = false; mutable std::mutex mMutex; std::condition_variable mWorkAvailable; }; diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 205943bb2..e6093f7e8 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -95,6 +95,9 @@ true + + true + @@ -913,62 +916,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -988,62 +940,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1063,62 +964,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1138,62 +988,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1213,62 +1012,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1288,62 +1036,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1363,62 +1060,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1439,62 +1085,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1515,62 +1110,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1590,62 +1134,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1666,62 +1159,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1741,62 +1183,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1804,7 +1195,6 @@ ecode-debug ProjectExplorer.CustomExecutableRunConfiguration - ../ true false false @@ -1817,62 +1207,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1892,62 +1231,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -1967,62 +1255,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2042,62 +1279,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2117,62 +1303,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2192,62 +1327,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2267,62 +1351,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2342,62 +1375,11 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false 0 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 @@ -2479,62 +1461,10 @@ cpu-cycles - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - -F true - 4096 - false - false - 1000 - true - - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - - 25 - - 1 true - false - true - - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 diff --git a/src/eepp/system/threadpool.cpp b/src/eepp/system/threadpool.cpp index 9c62c4f82..0f2cb47fc 100644 --- a/src/eepp/system/threadpool.cpp +++ b/src/eepp/system/threadpool.cpp @@ -2,21 +2,22 @@ namespace EE { namespace System { -std::shared_ptr ThreadPool::createShared( Uint32 numThreads ) { - std::shared_ptr pool( new ThreadPool( numThreads ) ); +std::shared_ptr ThreadPool::createShared( Uint32 numThreads, bool terminateOnClose ) { + std::shared_ptr pool( new ThreadPool( numThreads, terminateOnClose ) ); return pool; } -std::unique_ptr ThreadPool::createUnique( Uint32 numThreads ) { - std::unique_ptr pool( new ThreadPool( numThreads ) ); +std::unique_ptr ThreadPool::createUnique( Uint32 numThreads, bool terminateOnClose ) { + std::unique_ptr pool( new ThreadPool( numThreads, terminateOnClose ) ); return pool; } -ThreadPool* ThreadPool::createRaw( Uint32 numThreads ) { - return eeNew( ThreadPool, ( numThreads ) ); +ThreadPool* ThreadPool::createRaw( Uint32 numThreads, bool terminateOnClose ) { + return eeNew( ThreadPool, ( numThreads, terminateOnClose ) ); } -ThreadPool::ThreadPool( Uint32 numThreads ) { +ThreadPool::ThreadPool( Uint32 numThreads, bool terminateOnClose ) : + mTerminateOnClose( terminateOnClose ) { for ( Uint32 i = 0; i < numThreads; ++i ) { mThreads.emplace_back( std::make_unique( &ThreadPool::threadFunc, this ) ); mThreads.back().get()->launch(); @@ -32,7 +33,11 @@ ThreadPool::~ThreadPool() { mWorkAvailable.notify_all(); for ( auto& t : mThreads ) { - t.get()->wait(); + if ( terminateOnClose() ) { + t.get()->terminate(); + } else { + t.get()->wait(); + } } } @@ -60,6 +65,14 @@ void ThreadPool::threadFunc() { } } +bool ThreadPool::terminateOnClose() const { + return mTerminateOnClose; +} + +void ThreadPool::setTerminateOnClose( bool terminateOnClose ) { + mTerminateOnClose = terminateOnClose; +} + void ThreadPool::run( const std::function& func, const std::function& doneCallback ) { { @@ -68,7 +81,7 @@ void ThreadPool::run( const std::function& func, if ( mShuttingDown ) return; - mWork.emplace_back( new Work{func, doneCallback} ); + mWork.emplace_back( new Work{ func, doneCallback } ); } mWorkAvailable.notify_one(); diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index bd85e2e69..289fa36da 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -370,7 +370,7 @@ void App::onTextDropped( String text ) { } } -App::App() : mThreadPool( ThreadPool::createShared( eemax( 2, Sys::getCPUCount() ) ) ) {} +App::App() : mThreadPool( ThreadPool::createShared( eemax( 2, Sys::getCPUCount() ), true ) ) {} App::~App() { if ( mFileWatcher ) diff --git a/src/tools/codeeditor/formattermodule.cpp b/src/tools/codeeditor/formattermodule.cpp index a3a183dfb..15ffe87ed 100644 --- a/src/tools/codeeditor/formattermodule.cpp +++ b/src/tools/codeeditor/formattermodule.cpp @@ -135,11 +135,9 @@ void FormatterModule::runFormatter( UICodeEditor* editor, const Formatter& forma if ( 0 == result ) { std::string buffer( 1024, '\0' ); std::string data; - unsigned index = 0; unsigned bytesRead = 0; do { bytesRead = subprocess_read_stdout( &subprocess, &buffer[0], buffer.size() ); - index += bytesRead; data += buffer.substr( 0, bytesRead ); } while ( bytesRead != 0 ); diff --git a/src/tools/codeeditor/lintermodule.cpp b/src/tools/codeeditor/lintermodule.cpp index 046581816..c884ed6d1 100644 --- a/src/tools/codeeditor/lintermodule.cpp +++ b/src/tools/codeeditor/lintermodule.cpp @@ -220,11 +220,9 @@ void LinterModule::runLinter( std::shared_ptr doc, const Linter& l if ( 0 == result ) { std::string buffer( 1024, '\0' ); std::string data; - unsigned index = 0; unsigned bytesRead = 0; do { bytesRead = subprocess_read_stdout( &subprocess, &buffer[0], buffer.size() ); - index += bytesRead; data += buffer.substr( 0, bytesRead ); } while ( bytesRead != 0 );