Opened 20 years ago

Closed 16 years ago

#104 closed Bugs (None)

BCB6 throw EExternelException

Reported by: nobody Owned by: Roland Schwarz
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Borland C++ Builder 6 would throw an exception (
EExternelException )
in simple example:

--------   example in thread document -----
Simple usage of boost::thread

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

struct thread_alarm
{
   thread_alarm(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 << "alarm sounded..." << std::endl;
   }

   int m_secs;
};

int main(int argc, char* argv[])
{
   int secs = 5;
   std::cout << "setting alarm for 5 seconds..." <<
std::endl;
   thread_alarm alarm(secs);
   boost::thread thrd(alarm);
   thrd.join();
}

----- end of example -----

Change History (1)

comment:1 by Nicola Musatti, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=88359

When the example is modified to compile with Boost 1.33.1 it
executes without errors. Here's the corrected code:

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

struct thread_alarm
{
	thread_alarm(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 << "alarm sounded..." << std::endl;
	}

	int m_secs;
};

int main(int argc, char* argv[])
{
	int secs = 5;
	std::cout << "setting alarm for 5 seconds..." << std::endl;
	thread_alarm alarm(secs);
	boost::thread thrd(alarm);
	thrd.join();
}

Note: See TracTickets for help on using tickets.