Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

boost::thread under Borland Turbo

2 views
Skip to first unread message

Boogie

unread,
May 11, 2008, 7:48:21 AM5/11/08
to
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::operator() ()
{
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;
}

Boogie

unread,
May 11, 2008, 8:48:57 AM5/11/08
to
Sorry, code should be:

> // CRASHES HERE :
> serverThread = new boost::thread (Server::ServerThread ());

without "this" in constructor call.

B.

0 new messages