18 Aug 21:48
How to transform a single-threaded program into a multi-threaded program? (Source example)
From: Stephen Torri <storri <at> torri.org>
Subject: How to transform a single-threaded program into a multi-threaded program? (Source example)
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-08-18 19:50:11 GMT
Subject: How to transform a single-threaded program into a multi-threaded program? (Source example)
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-08-18 19:50:11 GMT
What I am trying to learn how to do is convert a single threaded program
into a multi-threaded program. The task of the program is to analyze a
text file a set number of times. Each analysis of the text file does not
depend on another. The only thing that they need is the name of the
file, how many iterations of the analysis to do and a unique id. I am
not concerned about the information from each round being printed in
sequential order. That is for example if thread A has a unique ID of 50
and thread B has a unique ID of 51 that I want thread B's output ahead
of thread A's output. The output is going to be captured into a file and
post-processed in a spreadsheet application.
Below is a running example of what I am trying to do.
To restate my question:
How do I use boost threads to make a multi-threaded version of
this program?
Stephen
----- EXAMPLE CODE -----
#include <boost/bind.hpp>
#include <boost/cstdint.hpp>
#include <boost/format.hpp>
#include <boost/program_options.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>
(Continue reading)
RSS Feed