/* -TAG:LICENSE-
   
   This file is under the DigitalSpark Freeware Class License, see the
   file LICENSE for complete licensing information.
                                                         
                                                         -TAG:LICENSE- */
#include <Threading.h>

extern	void *Accept( void );
extern	void *IRCServerManager( void );

extern int		listenfd;
extern pthread_t	KeeperPID;

/*
   The thread manager provides two things, a way to see if the program
   is all started up (ie; all the threads are up and running), and a
   way for only exiting until all the other threads are done closing up.

   NOTE: The threadmanager itself doesn't count in the ThreadCount, because
   it is considered the master thread, and does nothing that needs to be
   warned before exiting, and even if it did, it is the only thing that can
   declair an exit, so that's not and issue :)
*/

void *Manager( void )
{
pthread_t	ArbiterPID;

RegisterThread("ThreadManager","Manages Threads",FALSE);

/* 
   Waits until all the other threads are up and running before doing things.
   Useful so you don't start losing data because a thread hadn't started up
*/
// Nothing to do

/* Fork threads that need everything loaded */
pthread_create(&ArbiterPID, NULL, (void *)&Accept, NULL);
pthread_create(&ArbiterPID, NULL, (void *)&IRCServerManager, NULL);

pthread_exit(NULL);

return 0;
}
