OregonCore  revision be9e804-git
Your Favourite TBC server
MapUpdater Class Reference

#include <MapUpdater.h>

Public Member Functions

 MapUpdater ()
 
 ~MapUpdater ()
 
int schedule_update (Map &map, ACE_UINT32 diff)
 
int wait ()
 
int activate (size_t num_threads)
 
int deactivate ()
 
bool activated ()
 

Private Member Functions

void update_finished ()
 

Private Attributes

DelayExecutor m_executor
 
ACE_Condition_Thread_Mutex m_condition
 
ACE_Thread_Mutex m_mutex
 
size_t pending_requests
 

Friends

class MapUpdateRequest
 

Detailed Description

Definition at line 28 of file MapUpdater.h.

Constructor & Destructor Documentation

MapUpdater::MapUpdater ( )
inline

Definition at line 32 of file MapUpdater.h.

ACE_Thread_Mutex m_mutex
Definition: MapUpdater.h:51
size_t pending_requests
Definition: MapUpdater.h:52
DelayExecutor m_executor
Definition: MapUpdater.h:49
ACE_Condition_Thread_Mutex m_condition
Definition: MapUpdater.h:50
MapUpdater::~MapUpdater ( )
inline

Definition at line 33 of file MapUpdater.h.

References activate(), activated(), deactivate(), schedule_update(), and wait().

33 { };

Member Function Documentation

int MapUpdater::activate ( size_t  num_threads)

Definition at line 79 of file MapUpdater.cpp.

Referenced by MapManager::Initialize(), and ~MapUpdater().

80 {
81  return m_executor.activate((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1);
82 }
DelayExecutor m_executor
Definition: MapUpdater.h:49
int activate(int num_threads=1, ACE_Method_Request *pre_svc_hook=NULL, ACE_Method_Request *post_svc_hook=0)
bool MapUpdater::activated ( )

Definition at line 118 of file MapUpdater.cpp.

Referenced by MapManager::UnloadAll(), MapManager::Update(), and ~MapUpdater().

119 {
120  return m_executor.activated();
121 }
DelayExecutor m_executor
Definition: MapUpdater.h:49
int MapUpdater::deactivate ( )

Definition at line 84 of file MapUpdater.cpp.

Referenced by MapManager::UnloadAll(), and ~MapUpdater().

85 {
86  wait();
87 
88  return m_executor.deactivate();
89 }
int wait()
Definition: MapUpdater.cpp:91
DelayExecutor m_executor
Definition: MapUpdater.h:49
int MapUpdater::schedule_update ( Map map,
ACE_UINT32  diff 
)

Definition at line 101 of file MapUpdater.cpp.

Referenced by MapInstanced::Update(), MapManager::Update(), and ~MapUpdater().

102 {
103  ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
104 
106 
107  if (m_executor.execute(new MapUpdateRequest(map, *this, diff)) == -1)
108  {
109  ACE_DEBUG((LM_ERROR, ACE_TEXT("(%t) \n"), ACE_TEXT("Failed to schedule Map Update")));
110 
112  return -1;
113  }
114 
115  return 0;
116 }
ACE_Thread_Mutex m_mutex
Definition: MapUpdater.h:51
int execute(ACE_Method_Request *new_req)
size_t pending_requests
Definition: MapUpdater.h:52
DelayExecutor m_executor
Definition: MapUpdater.h:49
void MapUpdater::update_finished ( )
private

Definition at line 123 of file MapUpdater.cpp.

Referenced by MapUpdateRequest::call().

124 {
125  ACE_GUARD(ACE_Thread_Mutex, guard, m_mutex);
126 
127  if (pending_requests == 0)
128  {
129  ACE_ERROR((LM_ERROR, ACE_TEXT("(%t)\n"), ACE_TEXT("MapUpdater::update_finished BUG, report to devs")));
130  return;
131  }
132 
134 
135  m_condition.broadcast();
136 }
ACE_Thread_Mutex m_mutex
Definition: MapUpdater.h:51
size_t pending_requests
Definition: MapUpdater.h:52
ACE_Condition_Thread_Mutex m_condition
Definition: MapUpdater.h:50
int MapUpdater::wait ( )

Definition at line 91 of file MapUpdater.cpp.

Referenced by MapManager::Update(), and ~MapUpdater().

92 {
93  ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
94 
95  while (pending_requests > 0)
96  m_condition.wait();
97 
98  return 0;
99 }
ACE_Thread_Mutex m_mutex
Definition: MapUpdater.h:51
size_t pending_requests
Definition: MapUpdater.h:52
ACE_Condition_Thread_Mutex m_condition
Definition: MapUpdater.h:50

Friends And Related Function Documentation

friend class MapUpdateRequest
friend

Definition at line 33 of file MapUpdater.h.

Member Data Documentation

ACE_Condition_Thread_Mutex MapUpdater::m_condition
private

Definition at line 50 of file MapUpdater.h.

DelayExecutor MapUpdater::m_executor
private

Definition at line 49 of file MapUpdater.h.

ACE_Thread_Mutex MapUpdater::m_mutex
private

Definition at line 51 of file MapUpdater.h.

size_t MapUpdater::pending_requests
private

Definition at line 52 of file MapUpdater.h.


The documentation for this class was generated from the following files: