Boost logo

Boost :

From: William E. Kempf (wekempf_at_[hidden])
Date: 2002-10-29 10:49:28


Yakov Bachmutsky said:
>> Hot topic, but I don't see how this adds much utility. Maybe I'm just
>> not fully understanding you. Care to elaborate?
>
> static DWORD WINAPI CThread::ThreadProc(LPVOID pv)
> {
> CThread *pThread = (CThread*)pv;
> do
> {
> try
> {
> // startup
> if( !pThread->OnStartup() )
> break;
> // run
> pThread->m_dwExitCode = pThread->Run();
> // cleanup
> pThread->OnCleanup();
> break;
> }
> catch(...)
> {
> }
> if( !pThread->OnException() )
> /*****************************************/
> {
> pThread->OnCleanup();
> break;
> }
> }
> while(true);
> return pThread->m_dwExitCode;
> }
> // this function can be overriden to support other styles like class
> member functions.
> DWORD CThread::Run()
> {
> return (m_pHandler) (m_pParams);
> }

I still don't follow what this is supposed to do. Can you post a short
but complete example? Specifically, I can't tell if OnException() just
reports whether or not the thread was terminated by an uncaught exception,
or if it does something entirely different.

> The only thing I haven't mention yet, and I guess its no much interest
> as well, is that my threads have names(std::string)
> I'm just a fun of neat logs and so my thread class also logs that it
> started, ended and so on with its name inside.

This is actually something that may well be added to Boost.Threads, via
the upcoming "thread properties" (which will including things like thread
priority).

-- 
William E. Kempf

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk