(unknown)
Thomas Costa <[email protected]> Wed, 20 Sep 2006 11:45:05 -0700
| Newsgroups | gmane.comp.lib.jtc |
|---|---|
| Message-ID | <[email protected]> |
--===============24199386721873273==
Content-Type: multipart/alternative; boundary=Apple-Mail-1-82079308
--Apple-Mail-1-82079308
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
I am sorry if this a well documented issue but I couldn't find info
on it anywhere:
Why does it seem that JTCThreadGroup instances that are set to be
daemon do not in fact get destroyed when the last
JTCThreadGroupHandle to them goes out of scope and/or gets
destructed? They seem to only get destroyed when the root
JTCInitialize instance gets destructed.
It doesn't seem matter if the JTCThreadGroup is empty or has a
JTCThread associated with it (there is a "if (false)" in the code
below that will add a JTCThread to the group is it is changed to "if
(true)").
In fact, the JTCThread class seems to suffer from the same problem.
Here is the debugging output I am seeing and the code I am using.
OUTPUT
===========
2.0.1
Constructing MyThreadGroup...
MyThreadGroup::MyThreadGroup(Test Thread Group)
MyThreadGroup constructed (tgh=0x80550a8, refCount=2)
MyThreadGroup isDaemon()=false
MyThreadGroup daemonized (tgh=0x80550a8, refCount=2)
MyThreadGroup isDaemon()=true
JTCThreadGroupHandle going out of scope...
JTCThreadGroupHandle is out of scope and destructed
Sleeping...
Awake
JTCInitialize going out of scope...
MyThreadGroup::~MyThreadGroup(Test Thread Group)
JTCInitialize is out of scope and destructed
CODE
===========
#include <JTC/JTC.h>
using namespace ::std;
namespace {
class MyThreadGroup : public JTCThreadGroup {
public:
explicit MyThreadGroup( const string & name );
virtual ~MyThreadGroup( );
};
MyThreadGroup::MyThreadGroup( const string & name ) :
JTCThreadGroup( name.c_str() )
{
cout << "MyThreadGroup::MyThreadGroup(" << name << ")" << endl;
}
MyThreadGroup::~MyThreadGroup( )
{
cout << "MyThreadGroup::~MyThreadGroup(" << getName() << ")" <<
endl;
}
class MyThread : public JTCThread {
public:
explicit MyThread( JTCThreadGroupHandle & group,
const string & name );
virtual ~MyThread( );
virtual void run( );
};
MyThread::MyThread( JTCThreadGroupHandle & group,
const string & name ) :
JTCThread( group, name.c_str() )
{
cout << "MyThread::MyThread(" << name << ")" << endl;
}
MyThread::~MyThread( )
{
cout << "MyThread::~MyThread()" << endl;
}
void
MyThread::run( )
{
cout << "MyThread::run()" << endl;
}
int
loadData( )
{
{
cout << "Constructing MyThreadGroup..." << endl;
JTCThreadGroupHandle tgh = new MyThreadGroup( "Test Thread
Group" );
cout << "MyThreadGroup constructed (tgh="
<< static_cast< void * >( tgh.get() ) << ", refCount="
<< tgh->m_refcount << ")"
<< endl;
cout << "MyThreadGroup isDaemon()="
<< boolalpha << tgh->isDaemon()
<< endl;
tgh->setDaemon( true );
cout << "MyThreadGroup daemonized (tgh="
<< static_cast< void * >( tgh.get() ) << ", refCount="
<< tgh->m_refcount << ")"
<< endl;
cout << "MyThreadGroup isDaemon()=" << boolalpha << tgh-
>isDaemon() << endl;
if ( false ) {
{
JTCThreadHandle th = new MyThread( tgh, "Test
Thread" );
cout << "MyThread created (tgh="
<< static_cast< void * >( tgh.get() ) << ",
refCount="
<< tgh->m_refcount << ", th="
<< static_cast< void * >( th.get() ) << ",
refCount="
<< th->m_refcount << ")"
<< endl;
th->run();
cout << "MyThread run (tgh="
<< static_cast< void * >( tgh.get() ) << ",
refCount="
<< tgh->m_refcount << ", th="
<< static_cast< void * >( th.get() ) << ",
refCount="
<< th->m_refcount << ")"
<< endl;
th->join();
cout << "MyThread joined (tgh="
<< static_cast< void * >( tgh.get() ) << ",
refCount="
<< tgh->m_refcount << ", th="
<< static_cast< void * >( th.get() ) << ",
refCount="
<< th->m_refcount << ")"
<< endl;
cout << "Sleeping..." << endl;
sleep( 2 );
cout << "Awake (tgh="
<< static_cast< void * >( tgh.get() ) << ",
refCount="
<< tgh->m_refcount << ", th="
<< static_cast< void * >( th.get() ) << ",
refCount="
<< th->m_refcount << ")"
<< endl;
cout << "JTCThreadHandle going out of scope..." <<
endl;
}
cout << "JTCThreadHandle is out of scope (tgh="
<< static_cast< void * >( tgh.get() ) << ", refCount="
<< tgh->m_refcount << ")"
<< endl;
}
if ( false ) {
tgh->destroy();
cout << "MyThreadGroup destroyed (tgh="
<< static_cast< void * >( tgh.get() ) << ", refCount="
<< tgh->m_refcount << ")"
<< endl;
}
cout << "JTCThreadGroupHandle going out of scope..." << endl;
}
cout << "JTCThreadGroupHandle is out of scope and destructed" <<
endl;
return EXIT_SUCCESS;
}
} // namespace < anonymous >
int
carma::util::Program::main( )
try {
const int kArgc = 1;
int argc = kArgc;
char arg0[] = "-JTCversion";
char * argv[ kArgc ] = { arg0 };
int exitStatus = EXIT_FAILURE;
{
const JTCInitialize jtcInitialize( argc, argv );
exitStatus = loadData();
cout << "Sleeping..." << endl;
sleep( 5 );
cout << "Awake" << endl;
cout << "JTCInitialize going out of scope..." << endl;
}
cout << "JTCInitialize is out of scope and destructed" << endl;
return exitStatus;
} catch ( ... ) {
cerr << "Coming out on an exception: " << getStringForCaught()
<< endl;
throw;
}
--Apple-Mail-1-82079308
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=ISO-8859-1
<HTML><BODY style=3D"word-wrap: break-word; -khtml-nbsp-mode: space; =
-khtml-line-break: after-white-space; ">I am sorry if this a well =
documented issue but I couldn't find info on it anywhere:<DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>Why does it seem that =
JTCThreadGroup instances that are set to be daemon do not in fact get =
destroyed when the last JTCThreadGroupHandle to them goes out of scope =
and/or gets destructed? They seem to only get destroyed when the root =
JTCInitialize instance gets destructed.</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>It doesn't seem matter if =
the JTCThreadGroup is empty or has a JTCThread associated with it (there =
is a "if (false)" in the code below that will add a JTCThread to the =
group is it is changed to "if (true)").</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>In fact, the JTCThread =
class seems to suffer from the same problem.</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>Here is the debugging =
output I am seeing and the code I am using.</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>OUTPUT</DIV><DIV>=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">2.0.1</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">Constructing =
MyThreadGroup...</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">MyThreadGroup::MyThreadGroup(Test Thread =
Group)</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">MyThreadGroup constructed (tgh=3D0x80550a8, =
refCount=3D2)</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">MyThreadGroup =
isDaemon()=3Dfalse</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">MyThreadGroup daemonized (tgh=3D0x80550a8, =
refCount=3D2)</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">MyThreadGroup =
isDaemon()=3Dtrue</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">JTCThreadGroupHandle going out of =
scope...</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">JTCThreadGroupHandle is out of scope and =
destructed</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">Sleeping...</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">Awake</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">JTCInitialize going out of =
scope...</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">MyThreadGroup::~MyThreadGroup(Test Thread =
Group)</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">JTCInitialize is out of scope and destructed</FONT></DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV>CODE</DIV><DIV>=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D</DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">#include =
<JTC/JTC.h></FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">using namespace =
::std;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">namespace =
{</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">class MyThreadGroup : =
public JTCThreadGroup {</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 public:</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 explicit =
MyThreadGroup( const string & name );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 virtual ~MyThreadGroup( );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">};</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">MyThreadGroup::MyThreadGroup( const string & name ) =
:</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">JTCThreadGroup( name.c_str() )</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">{</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cout << =
"MyThreadGroup::MyThreadGroup(" << name << ")" << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">MyThreadGroup::~MyThreadGroup( )</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">{</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cout << =
"MyThreadGroup::~MyThreadGroup(" << getName() << ")" =
<< endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">class MyThread : public =
JTCThread {</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 public:</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 explicit =
MyThread( JTCThreadGroupHandle & group,</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 const string &=A0 =A0 =A0 =A0=A0 name =
);</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 virtual ~MyThread( =
);</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 virtual void run( =
);</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">};</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">MyThread::MyThread( =
JTCThreadGroupHandle & group,</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 const string &=A0 =A0 =A0 =A0=A0 name ) =
:</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">JTCThread( group, name.c_str() )</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">{</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cout << =
"MyThread::MyThread(" << name << ")" << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">MyThread::~MyThread( =
)</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">{</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 cout << "MyThread::~MyThread()" << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">void</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">MyThread::run( )</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">{</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cout << =
"MyThread::run()" << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">}</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">int</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">loadData( )</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">{</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 {</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "Constructing MyThreadGroup..." << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 JTCThreadGroupHandle tgh =3D new =
MyThreadGroup( "Test Thread Group" );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 cout << "MyThreadGroup constructed =
(tgh=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">=A0 =A0 =A0 =A0 =A0 =A0=A0 << static_cast< void * >( =
tgh.get() ) << ", refCount=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< tgh->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "MyThreadGroup isDaemon()=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< boolalpha << tgh->isDaemon()</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =
tgh->setDaemon( true );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "MyThreadGroup daemonized (tgh=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< static_cast< void * >( tgh.get() ) << ", =
refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0 << =
tgh->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0=A0=
<< endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "MyThreadGroup isDaemon()=3D" << boolalpha << =
tgh->isDaemon() << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 if ( =
false ) {</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 {</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 JTCThreadHandle th =3D new MyThread( tgh, "Test Thread" =
);</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 cout << "MyThread created (tgh=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( tgh.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< tgh->m_refcount << ", th=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( th.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< th->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
th->run();</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 cout << "MyThread run (tgh=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( tgh.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< tgh->m_refcount << ", th=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( th.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< th->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
th->join();</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 cout << "MyThread joined (tgh=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( tgh.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< tgh->m_refcount << ", th=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( th.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< th->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cout << "Sleeping..." =
<< endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sleep( 2 );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cout << "Awake =
(tgh=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 << =
static_cast< void * >( tgh.get() ) << ", =
refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 << =
tgh->m_refcount << ", th=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << static_cast< void * >( th.get() ) =
<< ", refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span"=
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 =
<< th->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0=A0 << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cout << "JTCThreadHandle =
going out of scope..." << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
cout << "JTCThreadHandle is out of scope =
(tgh=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 << static_cast< void * =
>( tgh.get() ) << ", refCount=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0=A0 << tgh->m_refcount << =
")"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 }</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 if ( =
false ) {</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
tgh->destroy();</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
cout << "MyThreadGroup destroyed (tgh=3D"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0=A0 << static_cast< void * >( tgh.get() ) << ", =
refCount=3D"</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 << =
tgh->m_refcount << ")"</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0=A0 << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =
}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 cout << "JTCThreadGroupHandle =
going out of scope..." << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 cout << "JTCThreadGroupHandle is out =
of scope and destructed" << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 return =
EXIT_SUCCESS;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">}</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">}=A0 // namespace < =
anonymous ></FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier =
New">int</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier=
New">carma::util::Program::main( )</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">try =
{</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 const int kArgc =3D 1;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 int argc =3D =
kArgc;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 char arg0[] =3D "-JTCversion";</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 char * argv[ =
kArgc ] =3D { arg0 };</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 int exitStatus =3D=
EXIT_FAILURE;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New"><BR =
class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
{</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 const JTCInitialize jtcInitialize( argc, argv =
);</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 exitStatus =3D =
loadData();</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 =A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "Sleeping..." << endl;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 sleep( 5 );</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 =
</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 =A0 =A0 cout << "Awake" << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 =A0 =A0 cout =
<< "JTCInitialize going out of scope..." << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 }</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 </FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cout << =
"JTCInitialize is out of scope and destructed" << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New"><BR class=3D"khtml-block-placeholder"></FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 return =
exitStatus;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">} catch ( ... ) {</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">=A0 =A0 cerr << =
"Coming out on an exception: " << getStringForCaught() << =
endl;</FONT></DIV><DIV><FONT class=3D"Apple-style-span" face=3D"Courier =
New">=A0 =A0 </FONT></DIV><DIV><FONT class=3D"Apple-style-span" =
face=3D"Courier New">=A0 =A0 throw;</FONT></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Courier New">}</FONT></DIV><DIV><BR =
class=3D"khtml-block-placeholder"></DIV></BODY></HTML>=
--Apple-Mail-1-82079308--
--===============24199386721873273==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
_______________________________________________
JTC-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/jtc-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html
--===============24199386721873273==--