Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is deque thread-safe?

Status
Not open for further replies.

Skatanic

Programmer
Jun 25, 2002
37
US
I was wondering if anyone knew if it was possible, in ALL possible situations, to push into a queue made from a deque and pop from the queue from different threads without using some form of mutal exclusion? It seems like the push does not corrupt the other elements, but I don't know if that covers all the cases. I am going for speed here and waiting for the mutex and releasing the mutex is a lot of overhead. Eliminating that would be nice. Just wondering if it is possible...

-Skatanic
 
No.. nevermind... That can't work like that. I just got it to crash right after I posted the question. (I was even trying to stop the post from posting it was that soon ;-) )

There is the case when there is just one element in the queue. Pushing onto the queue has to edit the element for that iterator while the pop is erasing that iterator. I think it would work for all other cases though. But in any case it is back to the drawing board for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top