mutex

PHP 5.x syncronized file access (no database)

大憨熊 提交于 2020-01-13 09:43:27
问题 I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x. To formulate my problem with one example: I have an ASCII-file which only stores a number, the value of a page load counter. At application deployment the file will simply hold a 0. For each access the value will be incremented by one. The goal is to keep track of page loads. The problem comes when

Unhandled exception when using std::mutex instead of boost::mutex

荒凉一梦 提交于 2020-01-13 08:06:08
问题 I try to get rid of some of the boost dependencies in my code and instead use the new C++11 features (Visual Studio 2013). In one of my components I used boost::mutex together with boost::lock_guard<boost::mutex> and everything worked fine. When I use std::mutex together with std::lock_guard<std::mutex> instead, I get the following error when returning from main() . Unhandled exception at 0x7721E3BE (ntdll.dll) in GrabberTester.exe: 0xC0000005: Access violation reading location 0xA6A6B491.

Maintaining single instance application

时间秒杀一切 提交于 2020-01-13 06:26:06
问题 I have been working on this application of mine and got this problem. Running program through command line with different arguments opens different .exe process. My question is how can i prevent from opening same file few times, and is it possible to send new command line arguments to already open instance of application. Thanks. 回答1: There are standard .NET classes for that. Check out: http://www.openwinforms.com/single_instance_application.html http://www.smartasses.be/2009/04/24/single

Starvation with upgrade_lock

被刻印的时光 ゝ 提交于 2020-01-13 03:22:26
问题 I am trying to use Boost's upgrade_lock (using this example, but I run into a starvation issue. I am actually using the code from this post, but I wanted an up-to-date discussion. I run 400 threads after the WorkerKiller . I run into the exact same problem as anoneironaut , the author of the mentionned post. I have seen the proposition from Howard Hinnant , but I don't really want to include more external code (moreover I cannot get his to compile as of now) and a comment posted 6 months

Starvation with upgrade_lock

倾然丶 夕夏残阳落幕 提交于 2020-01-13 03:22:06
问题 I am trying to use Boost's upgrade_lock (using this example, but I run into a starvation issue. I am actually using the code from this post, but I wanted an up-to-date discussion. I run 400 threads after the WorkerKiller . I run into the exact same problem as anoneironaut , the author of the mentionned post. I have seen the proposition from Howard Hinnant , but I don't really want to include more external code (moreover I cannot get his to compile as of now) and a comment posted 6 months

Can't provoke Priority Inversion in C++

大城市里の小女人 提交于 2020-01-12 10:19:28
问题 I'm trying to provoke Priority Inversion on a small C++ program for demonstration purposes but I can't: The low priority thread that holds the mutex is not preempted and keeps running on the critical section. This is what I'm doing: // let's declare a global mutex pthread_mutex_t my_mutex; ... int main(int argc, char **argv) { ... pthread_t normal_thread; pthread_t prio_thread; pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); pthread_mutexattr_setprotocol (&attr, PTHREAD_PRIO_NONE);

Can't provoke Priority Inversion in C++

强颜欢笑 提交于 2020-01-12 10:19:13
问题 I'm trying to provoke Priority Inversion on a small C++ program for demonstration purposes but I can't: The low priority thread that holds the mutex is not preempted and keeps running on the critical section. This is what I'm doing: // let's declare a global mutex pthread_mutex_t my_mutex; ... int main(int argc, char **argv) { ... pthread_t normal_thread; pthread_t prio_thread; pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); pthread_mutexattr_setprotocol (&attr, PTHREAD_PRIO_NONE);

Can't provoke Priority Inversion in C++

两盒软妹~` 提交于 2020-01-12 10:19:12
问题 I'm trying to provoke Priority Inversion on a small C++ program for demonstration purposes but I can't: The low priority thread that holds the mutex is not preempted and keeps running on the critical section. This is what I'm doing: // let's declare a global mutex pthread_mutex_t my_mutex; ... int main(int argc, char **argv) { ... pthread_t normal_thread; pthread_t prio_thread; pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); pthread_mutexattr_setprotocol (&attr, PTHREAD_PRIO_NONE);

is it necessary to call pthread_mutex_destroy on a mutex?

半城伤御伤魂 提交于 2020-01-12 07:01:08
问题 I am using pthread_mutex_t in a C++ program, as follows: class Mutex : public noncopyable { public: Mutex() { pthread_mutex_init(&m_mutex, NULL); } void acquire() { pthread_mutex_lock(&m_mutex); } void release() { pthread_mutex_unlock(&m_mutex); } private: pthread_mutex_t m_mutex; }; (The class is not copyable - http://www.boost.org/doc/libs/1_53_0/boost/noncopyable.hpp) The thing that I don't understand - is it considered an error to not call pthread_mutex_destroy in the destructor? The

Cannot access private member declared in class 'QReadWriteLock'Error 1 error C2248: 'QReadWriteLock::QReadWriteLock'

最后都变了- 提交于 2020-01-10 05:05:24
问题 This really feels like a bug in Qt. Anyone has a solution or should I file it as a bug? #include <QReadWriteLock> class FileInfoWrapper { public: explicit FileInfoWrapper(const QFileInfo& _fileInfo); ~FileInfoWrapper(); private: // also tried public mutable QReadWriteLock lock_; Before even using it, I get the error: Error 1 error C2248: 'QReadWriteLock::QReadWriteLock' : cannot access private member declared in class 'QReadWriteLock' Doesn't matter if it's private/public or what classes I