multithreading - multithreaded linked list in C++ -


first little explanation of trying do:

my plan write program socket stream implemented using boost::asio library feeds data parser implemented using boost:spirit::qi. parser take packets , fill packet object , append object end of linked list of packet objects. packet processor read first object in list , processing , move onto next item , delete first.

i decided use linked list because if used std::queue have lock entire container every time stream added packet or processor removed 1 make 2 threads run more or less serially, avoid. plus queue class has tendency copy entire objects whereas linked list idea has benefit of creating object once , pointing it. avoid serializing whole business intend place boost:mutex mutexes in each node , locking them there. idea have socket stream create list , lock first node, populate node parser, create next node , lock it, unlock first node , move on next node work. way there's never unlocked node dangling @ end packet procesor may jump , delete under socket streams nose. packet processor check first node , try lock it, if locks processing , unlock it, next node , delete first node. way serialization limited times when packet processor has caught socket stream class.

so question is, before work of implementing this, sound idea? i've tried on trivial test , seems work alright can't think of serious issues long implement exception handling , take care free memory allocate, if can think of problems idea i've overlooked appreciate input. appreciate other suggestions might have either alternative or might make idea work better.

thanks in advance!

check article, it's multiple consumers, still brillant:

measuring parallel performance: optimizing concurrent queue


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -