Solved

c++ queue & thread pool

Posted on 2015-01-29
5
409 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
Comment Utility
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
Comment Utility
Thanks jkr.  I'm looking at QueueUserWorkItem first.  Interesting.
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
@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
Comment Utility
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
Comment Utility
Both great answers, thank you!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

771 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

16 Experts available now in Live!

Get 1:1 Help Now