mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7810] Moved ZThread related code on ACE framework.
Remove ZThread source code from mangos. Signed-off-by: AlexDereka <dereka.alex@gmail.com>
This commit is contained in:
parent
f117ce3420
commit
2aff48cc5d
182 changed files with 684 additions and 21041 deletions
99
src/shared/Threading.h
Normal file
99
src/shared/Threading.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (C) 2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef THREADING_H
|
||||
#define THREADING_H
|
||||
|
||||
#include <ace/Thread.h>
|
||||
#include <ace/TSS_T.h>
|
||||
#include <assert.h>
|
||||
#include "Errors.h"
|
||||
|
||||
namespace ACE_Based
|
||||
{
|
||||
|
||||
class Runnable
|
||||
{
|
||||
public:
|
||||
virtual ~Runnable() {}
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
enum Priority
|
||||
{
|
||||
Idle,
|
||||
Lowest,
|
||||
Low,
|
||||
Normal,
|
||||
High,
|
||||
Highest,
|
||||
Realtime,
|
||||
};
|
||||
|
||||
#define MAXPRIORITYNUM (Realtime + 1)
|
||||
|
||||
class ThreadPriority
|
||||
{
|
||||
public:
|
||||
ThreadPriority();
|
||||
int getPriority(Priority p) const;
|
||||
|
||||
private:
|
||||
int m_priority[MAXPRIORITYNUM];
|
||||
};
|
||||
|
||||
class Thread
|
||||
{
|
||||
public:
|
||||
Thread();
|
||||
Thread(Runnable& instance);
|
||||
~Thread();
|
||||
|
||||
bool start();
|
||||
bool wait();
|
||||
void destroy();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
void setPriority(Priority type);
|
||||
|
||||
static void Sleep(unsigned long msecs);
|
||||
static ACE_thread_t currentId();
|
||||
static ACE_hthread_t currentHandle();
|
||||
static Thread * current();
|
||||
|
||||
private:
|
||||
Thread(const Thread&);
|
||||
Thread& operator=(const Thread&);
|
||||
|
||||
static ACE_THR_FUNC_RETURN ThreadTask(void * param);
|
||||
|
||||
ACE_thread_t m_iThreadId;
|
||||
ACE_hthread_t m_hThreadHandle;
|
||||
Runnable * m_task;
|
||||
|
||||
typedef ACE_TSS<Thread> ThreadStorage;
|
||||
//global object - container for Thread class representation of every thread
|
||||
static ThreadStorage m_ThreadStorage;
|
||||
//use this object to determine current OS thread priority values mapped to enum Priority{}
|
||||
static ThreadPriority m_TpEnum;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue