Solved

c++ queue & thread pool

Posted on 2015-01-29
5
416 Views
Last Modified: 2015-02-03
Hi Experts,

I want to create a reliable thread pool that will execute jobs from a queue.  I probably should not reinvent the wheel, but I'm not sure if something good exists.

- Is there already some implementation that I can use here?
- If not, any suggestions on the algorithm?

Thank you,
Mike
0
Comment
Question by:thready
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 40577875
Windows already comes with built-in supportr for that with mechanisms like 'QueueUserWorkItem()' (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684957(v=vs.85).aspx), see e.g. http://www.codeproject.com/Articles/33352/Full-Multi-thread-Client-Server-Socket-Class-with ("Full Multi-thread Client/Server Socket Class with ThreadPool") on how to make use of that. Alternatively, chec out http://www.codeproject.com/Articles/6863/Windows-Thread-Pooling-and-Execution-Chaining ("Windows Thread Pooling and Execution Chaining") which accomplishes the same in a little bit more C++ way.
0
 
LVL 1

Author Comment

by:thready
ID: 40578443
Thanks jkr.  I'm looking at QueueUserWorkItem first.  Interesting.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 40586601
@Karrtik Iyer,

Non-compliant post deleted:
http://support.experts-exchange.com/customer/portal/articles/1162518

Please repost adhering to the terms.

Thanks,
phoffric
TA
0
 
LVL 15

Assisted Solution

by:Karrtik Iyer
Karrtik Iyer earned 250 total points
ID: 40586702
Hi,

Please check out boost threading library and its pool library.
http://www.boost.org/doc/libs/1_57_0/doc/html/thread.html
http://www.boost.org/doc/libs/1_57_0/libs/pool/doc/html/boost_pool/pool/introduction.html

Thanks,
 description of your file (required)
0
 
LVL 1

Author Closing Comment

by:thready
ID: 40587775
Both great answers, thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now