/*------------------------------------------------------------------------
 *
 *  File:	o1k_thread.h
 *  Revision:	1.2
 *  Last Mod:	15:49:39, 03/01/97
 *
 *  Description:
 *     Defines O1kThread object.
 *     
 *----------------------------------------------------------------------*/
#pragma ident	"@(#)o1k_thread.h	1.2\t97/03/01  "

#ifndef _O1K_THREAD_H
#define _O1K_THREAD_H

#include <thread.h>
#include <synch.h>

#include "o1k_defines.h"

#define O1K_THREAD_NAME_SIZE 40

typedef void* (*O1kThrdFunc)(void* vp);

/*------------------------------------------------------------------------
 *
 *  Class:	O1kThread
 *
 * Description:
 *     A O1kThread object implements a single thread. One can
 *     start and stop this thread. The user of the O1kThread
 *     object calls start() to start the thread. One must
 *     supply a O1kThrdFunc routine which is where the thread
 *     will start in. An optional arg can also be passed to
 *     the thread as its single parameter. Once started in this
 *     routine, the routine should call setStopped() with
 *     FALSE as a param. This will let start() know that
 *     the thread has started. The thread routine should
 *     monitor isEnabled() to determine if the thread is
 *     still enabled. When the thread routine returns, it
 *     need to call setStopped() with TRUE to let the
 *     O1kThread object know the thread is stopped.
 *     To stop a O1kThread objects thread just call stop().
 *     
 * Notes:
 *     
 *     
 *     
 *----------------------------------------------------------------------*/

class O1kThread {

public:

  O1kThread(char* n);
  ~O1kThread();

  Boolean isEnabled() const { return enabled; }
  Boolean isStopped() const { return stopped; }

  void    setEnabled(Boolean flag) { enabled = flag; }
  void    setStopped(Boolean flag) { stopped = flag; }

  int     start(O1kThrdFunc func, void* arg);
  int     stop();
  
private:

  thread_t handle;
  Boolean  enabled;
  Boolean  stopped;
  char     name[O1K_THREAD_NAME_SIZE];
};

#endif

