Stephen Torri | 18 Aug 21:48

How to transform a single-threaded program into a multi-threaded program? (Source example)

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)

Mike Marchywka | 19 Aug 00:12
Favicon

Re: How to transform a single-threaded program into a multi-threaded program? (Source example)


> From: storri <at> torri.org
> To: boost-users <at> lists.boost.org
> Date: Mon, 18 Aug 2008 14:50:11 -0500
> Subject: [Boost-users] How to transform a single-threaded program into a multi-threaded program?
(Source example)
>
> 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

Do you want to learn boost or threading? 

> 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?
>

(Continue reading)


Gmane