// -*-C++-*- 

/*  inc/platform/threads/ThreadFactory.hpp  */

/*
 * Author: Philogelos A. <Philogelos@yahoo.com>
 * Maintainer: Philogelos A.
 * Keywords: C++, library, containers
 *
 * Copyright (C) 1999 Philogelos A.
 *
 * This file is part of Quercus Robusta.
 *
 * Quercus Robusta is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this software; see the file COPYING.LIB.  If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */



#ifndef __THREADFACTORY_HPP__
#define __THREADFACTORY_HPP__

/* $Id$ */

#include "Top.hpp"
#include "defines.h"

/* #define DEF_THREAD_FACTORY Win32ThreadFactory */
#define DEF_THREAD_FACTORY PThreadFactory


#if defined( WANT_DEF_THREAD_FACTORY )
#if defined( DEF_THREAD_FACTORY )
#undef DEF_THREAD_FACTORY
#endif
#define DEF_THREAD_FACTORY WANT_DEF_THREAD_FACTORY
#endif


#define THR_FACTORY ThreadFactory::getDefaultFactory()
#define THR_SYSTEM  THR_FACTORY -> getThreadSystem()

interface Thread;
interface Runnable;
interface ThreadsSystem;
class List;
/**

   @author Philogelos
   @created
*/
abstract class ThreadFactory : public virtual Top
{

public: virtual Thread *createFromFunc( void * ( *aStartFunc )( void *anArg ), void *anArg ) = 0;
public: virtual Thread *createFromRunner( Runnable *aRunner );
public: virtual Thread *createFromMethod( Top *anObject, 
									  void *( Top::*aMethod )(), char );
public: virtual ThreadsSystem *getThreadSystem() = 0;
public: virtual List *listThreads() const;

public: static ThreadFactory *getDefaultFactory();

protected: ThreadFactory();
protected: virtual ~ThreadFactory();

protected: List *threads;
protected: static ThreadFactory *instance;
};

typedef struct
{
  Top *object;
  union
  {
	void *( Top::*nilaryMethod )();
	void *( Top::*unaryMethod )( Top *anArg );
	void *( Top::*binaryMethod )( Top *anArg1, Top *anArg2 );
  } arity;
  void *arg;
} MethodCall;
/* $Log$ */

/* __THREADFACTORY_HPP__ */
#endif
