Comments (9)
This could occur if there's more than one thread consuming from the queue.
Also, please update to the latest master, there were some fixes around signals while blocking on the semaphore at one point.
from readerwriterqueue.
Good to know, thanks for the quick reply! We'll update to latest master and verify that we don't have multiple consumers.
from readerwriterqueue.
@cameron314 Hi, this issue is not fixed with the latest master. Can I just remove this assert directly? Thanks!
from readerwriterqueue.
No, if this assert is firing it indicates a bug somewhere, either in the queue or in the calling code. Can you share an example that reproduces?
from readerwriterqueue.
Here is the example source code:
#include <unistd.h>
#include <iostream>
#include <thread>
#include "readerwriterqueue.h"
typedef moodycamel::BlockingReaderWriterQueue<int> InputQueue;
auto input_queue = std::make_shared<InputQueue>();
void
startWorkLoop()
{
while (true) {
int input = 0;
input_queue->wait_dequeue(input);
}
}
void
startClientLoop()
{
while (true) {
sleep(2);
std::cout << "enqueue ..." << std::endl;
int input = 1;
input_queue->enqueue(input);
}
}
int
main(int argc, char **argv)
{
std::shared_ptr<std::thread> thread1 = std::make_shared<std::thread>(&startWorkLoop);
std::shared_ptr<std::thread> thread2 = std::make_shared<std::thread>(&startWorkLoop);
std::shared_ptr<std::thread> client = std::make_shared<std::thread>(&startClientLoop);
thread1->join();
thread2->join();
client->join();
return 0;
}
Here is the CMakeLists.txt
cmake_minimum_required(VERSION 3.10.1)
project(verify)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17 -pthread -W")
set(CMAKE_BUILD_TYPE "Debug")
add_executable(main main.cc)
OS: Ubuntu 20.04
from readerwriterqueue.
You have one producer thread but two consumer threads. This is an SPSC queue (supports single consumer only).
from readerwriterqueue.
This could occur if there's more than one thread consuming from the queue.
Also, please update to the latest master, there were some fixes around signals while blocking on the semaphore at one point.
I thought this had been fixed.
B.T.W. If I want to support multiple producers multiple consumers and keep consuming in order, what should I use?
Thanks.
from readerwriterqueue.
This could occur if there's more than one thread consuming from the queue.
Also, please update to the latest master, there were some fixes around signals while blocking on the semaphore at one point.I thought this had been fixed.
B.T.W. If I want to support multiple producers multiple consumers and keep consuming in order, what should I use?
Thanks.
Have you solved this issue? I am in a single producer and single consumer mode, and I have also encountered this error. I receive moodycamel::BlockingReaderWriterQueue enqueue from multiple network interfaces, and then wait_dequeue in a sub-thread.
from readerwriterqueue.
I thought this had been fixed.
The issue was with your example code.
B.T.W. If I want to support multiple producers multiple consumers and keep consuming in order, what should I use?
You'd need to find another queue implementation. I don't have an MPMC queue with global ordering.
I receive moodycamel::BlockingReaderWriterQueue enqueue from multiple network interfaces, and then wait_dequeue in a sub-thread.
Are you enqueueing from multiple threads?
from readerwriterqueue.
Related Issues (20)
- Circular Buffer force_enque HOT 5
- some questions HOT 3
- Queue as member variable breaks my program HOT 2
- Any way to copy a string into an element atomically? HOT 4
- Please add to README how to run tests HOT 1
- On an M1 on MacOS, when profiling with Tracy, ReadWriterQueue's try_enqueue / try_dequeue sometimes seem to cause spikes of several milliseconds HOT 6
- Deadlock with readerwriterqueue when spinning over try_enqueue() method HOT 1
- peek() method for BlockingReaderWriterCircularBuffer? HOT 4
- Circular Buffer Doesn't Overwrite Old Data HOT 2
- Help with profiling OSX M1 HOT 17
- Any plan on latest release tag HOT 2
- Memory allocation HOT 2
- Upload stable release archive HOT 1
- same content poped when queue should be empty HOT 1
- Is Runtime Allocation Possible HOT 2
- Supported platforms/operating systems? HOT 3
- Assertion `!inSection && "Concurrent (or re-entrant) enqueue or dequeue operation detected (only one thread at a time may hold the producer or consumer role) HOT 1
- Segfault when attempting to peek() into the queue std::__atomic_base<bool>::load (__m=std::memory_order_relaxed, HOT 2
- Folly's LockFreeRingBuffer HOT 2
- can i use readwritequeue? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from readerwriterqueue.