multithreading

C++ freeRTOS Task, invalid use of non-static member function

雨燕双飞 提交于 2021-02-07 09:13:51
问题 Where is the Problem? void MyClass::task(void *pvParameter){ while(1){ this->update(); } } void MyClass::startTask(){ xTaskCreate(this->task, "Task", 2048, NULL, 5, NULL); } But, I get this: error: invalid use of non-static member function I cannot find any useful doc to check where is the mistake, but i think that should be something like: (C++11's std::thread) e.g.: xTaskCreate(&MyClass::task, "Task", 2048, (void*)this, 5, NULL); solution that works for me: void MyClass::task(){ while(1){

Java happens-before relationship invokeAndWait

天涯浪子 提交于 2021-02-07 09:07:40
问题 My question is related to this question, which already has an answer: yes, there is a happens-before relationship imposed between actions of the thread calling invokeLater / invokeAndWait and actions on the EDT of the runnable thereby submitted. My question is a bit more general: Is it even possible to implement a method, such as invokeAndWait , such that it works properly , but not imposing a happens-before relationship? By the method working properly I mean the following: The submitted

Single reader multiple writers with pthreads and locks and without boost

别等时光非礼了梦想. 提交于 2021-02-07 08:58:58
问题 Consider the next piece of code. #include <iostream> #include <vector> #include <map> using namespace std; map<pthread_t,vector<int>> map_vec; vector<pair<pthread_t ,int>> how_much_and_where; pthread_cond_t CV = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void* writer(void* args) { while(*some condition*) { int howMuchPush = (rand() % 5) + 1; for (int i = 0; i < howMuchPush; ++i) { // WRITE map_vec[pthread_self()].push_back(rand() % 10); } how_much_and_where

Java happens-before relationship invokeAndWait

社会主义新天地 提交于 2021-02-07 08:58:56
问题 My question is related to this question, which already has an answer: yes, there is a happens-before relationship imposed between actions of the thread calling invokeLater / invokeAndWait and actions on the EDT of the runnable thereby submitted. My question is a bit more general: Is it even possible to implement a method, such as invokeAndWait , such that it works properly , but not imposing a happens-before relationship? By the method working properly I mean the following: The submitted

Dropwizard @UnitOfWork with asynchronous database call

六月ゝ 毕业季﹏ 提交于 2021-02-07 08:58:42
问题 I imagine that this is a common problem, but after some searching I wasn't able to find anything relevant. The problem I'm having is that I'm getting a No Hibernate Session bound to thread exception when annotating my resource method with @UnitOfWork and inside my resource method, making an asynchronous DAO call. The idea behind this design is to make the database call on a separate I/O thread so that it frees up the Jersey resource thread. Unfortunately, as the exception says, this

Dropwizard @UnitOfWork with asynchronous database call

妖精的绣舞 提交于 2021-02-07 08:58:30
问题 I imagine that this is a common problem, but after some searching I wasn't able to find anything relevant. The problem I'm having is that I'm getting a No Hibernate Session bound to thread exception when annotating my resource method with @UnitOfWork and inside my resource method, making an asynchronous DAO call. The idea behind this design is to make the database call on a separate I/O thread so that it frees up the Jersey resource thread. Unfortunately, as the exception says, this

Hibernate thread-safe collections

人走茶凉 提交于 2021-02-07 08:57:37
问题 This is somewhat of a continuation of Hibernate session thread safety. All of the details apply here as well. In simplified terms, execution follows the pattern of: 1. Read entity 2. Do expensive, easily parallelizable work 3. Persist changes The entities are all configured for eager loading, and the session is not accessed at all during 2. The work involved in 2 requires infrequent modification of a persistent collection. This is what I have now: synchronized (parentEntity) { parentEntity

Single reader multiple writers with pthreads and locks and without boost

早过忘川 提交于 2021-02-07 08:57:21
问题 Consider the next piece of code. #include <iostream> #include <vector> #include <map> using namespace std; map<pthread_t,vector<int>> map_vec; vector<pair<pthread_t ,int>> how_much_and_where; pthread_cond_t CV = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void* writer(void* args) { while(*some condition*) { int howMuchPush = (rand() % 5) + 1; for (int i = 0; i < howMuchPush; ++i) { // WRITE map_vec[pthread_self()].push_back(rand() % 10); } how_much_and_where

Java happens-before relationship invokeAndWait

血红的双手。 提交于 2021-02-07 08:57:21
问题 My question is related to this question, which already has an answer: yes, there is a happens-before relationship imposed between actions of the thread calling invokeLater / invokeAndWait and actions on the EDT of the runnable thereby submitted. My question is a bit more general: Is it even possible to implement a method, such as invokeAndWait , such that it works properly , but not imposing a happens-before relationship? By the method working properly I mean the following: The submitted

Hibernate thread-safe collections

那年仲夏 提交于 2021-02-07 08:56:53
问题 This is somewhat of a continuation of Hibernate session thread safety. All of the details apply here as well. In simplified terms, execution follows the pattern of: 1. Read entity 2. Do expensive, easily parallelizable work 3. Persist changes The entities are all configured for eager loading, and the session is not accessed at all during 2. The work involved in 2 requires infrequent modification of a persistent collection. This is what I have now: synchronized (parentEntity) { parentEntity