winix/core/threadmanager.h

56 lines
920 B
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_threadmanager
#define headerfile_winix_core_threadmanager
#include <vector>
#include "basethread.h"
#include "synchro.h"
class ThreadManager
{
public:
ThreadManager();
// synchro object
void SetSynchro(Synchro * psynchro);
// initializing
void Init();
// adding a new thread to the queue
// the thread will be running only if we call StartAll() before
// otherwise the thread will be waiting for StartAll()
void Add(BaseThread * pbase);
// starting all threads
void StartAll();
// sending a stop signal to all threads
// and waiting until they finish
void StopAll();
private:
Synchro * synchro;
typedef std::vector<BaseThread*> ThreadTab;
ThreadTab thread_tab;
bool were_started;
void Start(size_t i);
};
#endif