Boost logo

Boost Users :

From: Harm de Laat (harm_at_[hidden])
Date: 2002-03-14 08:39:59


Hi all,

I'm new to Boost and relativily new to C++. I'm trying to program threads on my Redhat 7.2 linux.

I have the following code:

#include <iostream>
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>

struct thread_struct
{
    thread_struct(int secs) : m_secs(secs) {}
    void operator ()()
    {
        boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC);
        xt.sec += m_secs;

        boost::thread::sleep(xt);
        std::cout << "Boosted!!!" << std::endl;
    }

    int m_secs;
};

int main (int argc, char* argv[]) {
    int secs = 5;
    std::cout << "Starting..." << std::endl;
    thread_struct ts(secs);
    boost::thread thrd(ts);
    thrd.join();
}

The code compiles without any problems... But do I have link it against some library? Because I cannot link it to an
executable file. I'm new to this. So can somebody please be so kind to help me and describe the steps nessecary to run
this Thread example file...

Many Thanks,

Harm de Laat
Informatiefabriek
The Netherlands


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net