Saturday, July 16, 2011
Multithreaded linked list in C++?
I'm trying to write a socket based program that will pull packets off a stream and parse them into a linked list that will then be processed to do actual work in another thread. My idea, though, to keep the socket stream and parser moving along and prevent the socket thread and the processor thread from ultimately being extremely serial, is to place the mutex for each node within the node itself and have the stream thread lock each node as it creates it, parse the packet and fill the node, then create the next node and lock that one before unlocking the node it just finished with. The processor thread will then follow behind attempting to lock each node before working on it, doing its work, then unlocking and deleting the node. Before I dedicate a lot of time implementing this, though, I was wondering if anyone could think of anything I've overlooked, or has any better ideas or suggestions?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment