Category : multithreading

I’m using drogon with main function like this #include <memory> using namespace drogon; int main() { app().setLogPath("./") .setLogLevel(trantor::Logger::kWarn) .addListener("0.0.0.0", 8080) .setThreadNum(4) .enableGzip(false) ; app().run(); } I have one controller class that allocates resources in constructor (like memory, handles etc.). There are 4 threads for whole service (configured above in main). Is there a possibility that ..

Read more

This is happening in Python 3.6.7 from non-python created threads: Can we do Py_Finalize() from other than main thread ? thread 1: Py_Initialize(); PyRun_SimpleString("import os"); PyRun_SimpleString("import sys"); PyObject* module = PyImport_ImportModule("os"); std::string scriptPath = installRoot+"/share/uxe/bin"; std::string path = "sys.path.append ("" + scriptPath + "")"; PyRun_SimpleString(path.c_str()); PyObject * import = PyImport_ImportModule("Infer_Gplace"); PyObject * attr = PyObject_GetAttrString(import, ..

Read more

I wrote the following parallel implementation of std::accumulate, It’s giving a compilation error. error: called object type ‘int’ is not a function or function pointer threads[i] = thread(batch_sum<Iterator, T>, block_start, block_end, ref(results[i])); How do I fix this? #include <iostream> #include <thread> #include <algorithm> #include <numeric> #include <vector> #define BATCH_SIZE 250 using namespace std; template<typename Iterator, ..

Read more

Thread newbie here. In the following code, I want to add elements to the global list using one thread and search for random elements using another thread. #include <list> #include <algorithm> #include <mutex> #include <thread> using namespace std; list<int> some_list; mutex some_mutex; void add_to_list(int new_value) { lock_guard<mutex> guard(some_mutex); some_list.push_back(new_value); } bool list_contains(int value_to_find) { lock_guard<mutex> ..

Read more

Description: I have multiple threads (4-32). These threads can all access an array: int resources[1024]. Resources array contains different values (0-1023). There can only be one instance of a single resource(int). Each thread requires different number of resources, which are at some point returned back to the array. Threads can ask for resources more than ..

Read more

For the next question of Strange Efficiency Decrease when Localizing a Global Variable into a Subthread, resently I found the question of the efficienct decreasement is actually caused by moving the CreatePen code into a thread, where it was originally placed in a WindowProc/WndProc function, but I have no idea with the detail. Could anyone ..

Read more