boost-interprocess

boost named_condition is not waking up waiting process

陌路散爱 提交于 2019-12-01 12:34:36
问题 I have 2 processes (producer and consumer) sharing an int deque in shared memory, I have the producer process put 2 numbers in the deque and then it gets in a wait state losing its mutex lock. I then have the consumer process removing the numbers and printing them. It then does a notify on the condition which the producer is waiting on. The consumer then goes on its own wait on a second condition. After this case the producer does not wake up. I am using the same mutex between the processes.

Is boost::interprocess::shared_ptr threadsafe (and interprocess-safe)?

巧了我就是萌 提交于 2019-12-01 04:28:01
I want to share data between threads, and have it automatically deleted when the last user is done with it. This seems to work, most of the time, using boost::interprocess::shared_ptr in a boost::fixed_managed_shared_memory segment: but not always. So, is boost::interprocess::shared_ptr thread (and interprocess) -safe? If I'm using my shared memory at a fixed address (I'm pretty certain this is going to be okay in my 64-bit (well, 48-bit) address space), is it possible to use a normal boost::shared_ptr (which are threadsafe) instead? some clarification: The pointer type I use is plain void* ,

Is boost::interprocess::shared_ptr threadsafe (and interprocess-safe)?

纵饮孤独 提交于 2019-12-01 03:16:36
问题 I want to share data between threads, and have it automatically deleted when the last user is done with it. This seems to work, most of the time, using boost::interprocess::shared_ptr in a boost::fixed_managed_shared_memory segment: but not always. So, is boost::interprocess::shared_ptr thread (and interprocess) -safe? If I'm using my shared memory at a fixed address (I'm pretty certain this is going to be okay in my 64-bit (well, 48-bit) address space), is it possible to use a normal boost:

Setting permission for shared memory created by boost

∥☆過路亽.° 提交于 2019-11-30 13:54:44
问题 We open a boost shared memory that was created by another process like this boost::interprocess::managed_shared_memory segment(boost::interprocess::open_only, "SharedMem"); But if the process that created the shared memory was a root user, then the process reading it, if it was a normal user, will fail with the reason as: terminate called after throwing an instance of 'boost::interprocess::interprocess_exception' what(): Permission denied What should i do to avoid this? that is to give

Synchronized stored procedure execution in mysql

谁都会走 提交于 2019-11-30 13:39:59
I have a stored procedure in mysql thats to perform a task that needs to be synchronized such that if two application calls the stored procedure, only one can access a section of code to perform the task, keeping the other one to get blocked until the first one finishes the task. DELIMITER $$ CREATE PROCEDURE SP_GEN_ID(IN NAME VARCHAR(20)) BEGIN DECLARE maxLen int default 0; START TRANSACTION; #the section of code that needs to be synchronized COMMIT END; $$ DELIMITER ; So, if two applications call the stored procedure simultaneously, the task has to be synchronized. a. But Start TRANSACTION

How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?

做~自己de王妃 提交于 2019-11-30 07:33:07
问题 My scenario: one server and some clients (though not many). The server can only respond to one client at a time, so they must be queued up. I'm using a mutex ( boost::interprocess::interprocess_mutex ) to do this, wrapped in a boost::interprocess::scoped_lock . The thing is, if one client dies unexpectedly (i.e. no destructor runs) while holding the mutex, the other clients are in trouble, because they are waiting on that mutex. I've considered using timed wait, so if I client waits for, say,

Create a shared-memory vector of strings

霸气de小男生 提交于 2019-11-29 04:37:30
I am trying to create a class managing a shared-memory vector of (std)strings. typedef boost::interprocess::allocator<std::string, boost::interprocess::managed_shared_memory::segment_manager> shmem_allocator; typedef boost::interprocess::vector<std::string, shmem_allocator> shmem_vector; shmem_mgr::shmem_mgr() : shmem_(create_only, SHMEM_KEY, SHMEM_SIZE), allocator_(shmem_.get_segment_manager()) { mutex_ = shmem_.find_or_construct<interprocess_mutex>(SHMEM_MUTEX)(); condition_ = shmem_.find_or_construct<interprocess_condition>(SHMEM_CONDITION)(); //buffer_ is of type shmem_vector buffer_ =

How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?

可紊 提交于 2019-11-29 04:25:32
My scenario: one server and some clients (though not many). The server can only respond to one client at a time, so they must be queued up. I'm using a mutex ( boost::interprocess::interprocess_mutex ) to do this, wrapped in a boost::interprocess::scoped_lock . The thing is, if one client dies unexpectedly (i.e. no destructor runs) while holding the mutex, the other clients are in trouble, because they are waiting on that mutex. I've considered using timed wait, so if I client waits for, say, 20 seconds and doesn't get the mutex, it goes ahead and talks to the server anyway. Problems with this

How can I achieve something similar to a semaphore using boost in c++? [duplicate]

不想你离开。 提交于 2019-11-28 09:21:43
This question already has an answer here: C++0x has no semaphores? How to synchronize threads? 9 answers I noticed that boost does not seem to support semaphores. What's the easiest way to achieve a similar effect? You either need Boost Interprocess semaphore or Boost Thread synchronization primitives. Mutex/Lock and condition are primitives that are commonly used to synchronize access to shared resources across multiple threads of a single process. There are exclusive , readers-writer and recursive/reentrant types of mutexes. Mutex, in other words, is an exclusive lock. Condition is used to

boost::interprocess scoped_allocator AND Containers of containers NOT in shared memory

荒凉一梦 提交于 2019-11-28 01:38:15
I have a similar question as before in boost::interprocess Containers of containers NOT in shared memory and How to I create a boost interprocess vector of interprocess containers but this time I like to use my class, which uses a scoped_allocator, also on the heap and shared memory. The solution to my first question was to use a template class with an allocator type In my second previous question it turned out that using a scoped_allocator together with a container of containers within the shared memory makes live easier. Now I like to have both, is this possible? Attached a example with a