/* -*-c++-*- header - Open Producer - Copyright (C) 2002 Don Burns
 * Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
 * as published by the Free Software Foundation.
 */
#ifndef PRODUCER_THREAD
#define PRODUCER_THREAD 1

#include <Producer/Export>

#ifdef _USE_OPEN_THREAD // [

#include <OpenThread/Thread.h>

namespace Producer {

class PR_EXPORT Thread  : public OpenThread::Thread
{
    public:
        Thread() : OpenThread::Thread() {}
        virtual ~Thread() 
        { 
            printf( "Thread %d destructor called\n", getpid() );
        }
};

}

#else // ][ 

#include <pthread.h>

namespace Producer {

class PR_EXPORT Thread 
{
    public:
    Thread() ;
    virtual ~Thread();

    size_t getStackSize();

    pthread_t getThreadID(); 

    void setStackSize( size_t size );

    void setProcessorAffinity( int cpunum );

    void startThread();

    void join();

    void cancel();

    virtual void run() = 0;

    bool threadIsRunning();

    private:

        static void *s_StartThread(void *data);

        pthread_t _tid;
        pthread_attr_t _attr;
        int _runon;
        bool _threadIsRunning;
};

}

#endif // ]

#endif
