Bug in JTC 1.0.14?
Matt Hammond <[email protected]> Tue, 16 Sep 2003 12:44:10 +0100
| Newsgroups | gmane.comp.lib.jtc |
|---|---|
| Message-ID | <5.2.0.9.0.20030916122943.00b1a128@pop3> |
Wonder if anyone can shed any light on this:
The example code (see below) seg-faults after a varying number of
iterations round the for-loop in main(). However, it works fine if I
replace the JTCThreadHandle private member with a JTCHandleT<...>
specifically for my derived class.
I'm still comparatively new at using JTC, so perhaps I'm just missing
something really obvious? Or is this a bug? :-)
If the bug doesn't manifest, try increasing the number of iterations in the
for-loop.
I'm using JTC 1.0.14, statically linked on a SUSE 7.3 Linux machine with
GCC 2.95.3.
cheers,
-- start of code --
#include <iostream>
#include "JTC/JTC.h"
class MyThread
{
public:
virtual void run()
{ };
};
class Launcher
{
private:
class m_Thread : public virtual JTCThread
{
private:
MyThread &m_target;
public:
m_Thread(MyThread &target) : m_target(target)
{ };
virtual ~m_Thread()
{ };
virtual void run()
{ m_target.run(); }
};
JTCThreadHandle m_thread; // !! comment me out to stop it
crashing
// JTCHandleT<m_Thread> m_thread; // !! un-comment me to stop it
crashing
public:
Launcher(MyThread &target)
{ m_thread = new m_Thread(target);
m_thread->start();
};
~Launcher()
{
while (m_thread->isAlive())
try
{ m_thread->join(); }
catch (const JTCInterruptedException &)
{ };
};
};
int main(int, char**)
{
JTCInitialize init;
MyThread mt;
Launcher *lt;
for(int i=0; i<10000; i++)
{
std::cout<<i<<endl;
lt = new Launcher(mt);
delete lt;
};
cout<<endl;
return 0;
};
-- end of code --
| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
_______________________________________________
JTC-Users Mailing List - [email protected]
http://www.orbacus.com/mailman/listinfo/jtc-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html