Files
winix/core/threadmanager.h
Tomasz Sowa 7468e7a36c added: namespace Winix over all *.h/*.cpp files
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@948 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-02-12 16:30:49 +00:00

75 lines
1.2 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_threadmanager
#define headerfile_winix_core_threadmanager
#include <string>
#include <vector>
#include "basethread.h"
#include "synchro.h"
namespace Winix
{
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, const wchar_t * thread_name);
void Add(BaseThread & pbase, const wchar_t * thread_name);
void Add(BaseThread * pbase, const std::wstring & thread_name);
void Add(BaseThread & pbase, const std::wstring & thread_name);
// starting all threads
void StartAll();
// sending a stop signal to all threads
// and waiting until they finish
void StopAll();
private:
struct ThreadItem
{
BaseThread * object;
std::wstring name;
};
Synchro * synchro;
typedef std::vector<ThreadItem> ThreadTab;
ThreadTab thread_tab;
bool were_started;
void Start(size_t i);
};
} // namespace Winix
#endif