boost::thread under Borland Turbo

B

Boogie

Hi,

A specific problem arises when I try to use boost::thread 1.35.0 with
Borland Turbo 2006.
Code below compiles but when run it throws (in commented line - thread
creation):
"assertion failed: p_ != 0, file .\boost/intrusive_ptr.hpp, line 126"
(thread holds NULL pointer to thread function)
I've tested this code under gcc 3.4 (mingw32) and gcc 3.2 (linux) - it
worked fine in both cases.
Is there any workaround for this? I've tried googling and boost docs
but didn't find anything...


// file Server.h
//---------------------------------------------------

class Server {
class ServerThread {
public: ServerThread () { }
ServerThread (const ServerThread &other) { }
~ServerThread () { }
void operator() ();
};

public: Server () : serverThread (NULL) { }
Server (const Server &other) : serverThread
(other.serverThread) { }
~Server () { }

void StartServer (void);
void StopServer (void);

private: boost::thread *serverThread;
};

// file Server.cpp
//---------------------------------------------------

void Server::ServerThread::eek:perator() ()
{
while (1) { /* doing anything */ }
}

void Server::StartServer (void)
{
if (!serverThread)
{
// CRASHES HERE :
serverThread = new boost::thread (Server::ServerThread (this));
}
}

void Server::StopServer (void)
{
if (serverThread)
{
serverThread->interrupt();
delete serverThread;
serverThread = NULL;
}
}

// file main.cpp
//---------------------------------------------------
#include "Server.h"

int main (void)
{
Server server;
server.StartServer();
server.StopServer();

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top