TrinityCore
Loading...
Searching...
No Matches
MapUpdater.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _MAP_UPDATER_H_INCLUDED
19
#define _MAP_UPDATER_H_INCLUDED
20
21
#include "
Define.h
"
22
#include <mutex>
23
#include <thread>
24
#include <condition_variable>
25
#include "
ProducerConsumerQueue.h
"
26
27
class
MapUpdateRequest
;
28
class
Map
;
29
30
class
TC_GAME_API
MapUpdater
31
{
32
public
:
33
34
MapUpdater
() : _cancelationToken(false), pending_requests(0) {}
35
~MapUpdater
() { };
36
37
friend
class
MapUpdateRequest
;
38
39
void
schedule_update(
Map
& map,
uint32
diff);
40
41
void
wait();
42
43
void
activate(
size_t
num_threads);
44
45
void
deactivate();
46
47
bool
activated();
48
49
private
:
50
51
ProducerConsumerQueue<MapUpdateRequest*>
_queue
;
52
53
std::vector<std::thread>
_workerThreads
;
54
std::atomic<bool>
_cancelationToken
;
55
56
std::mutex
_lock
;
57
std::condition_variable
_condition
;
58
size_t
pending_requests
;
59
60
void
update_finished();
61
62
void
WorkerThread();
63
};
64
65
#endif
//_MAP_UPDATER_H_INCLUDED
Define.h
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:114
uint32
uint32_t uint32
Definition
Define.h:133
ProducerConsumerQueue.h
MapUpdateRequest
Definition
MapUpdater.cpp:26
MapUpdater
Definition
MapUpdater.h:31
MapUpdater::_workerThreads
std::vector< std::thread > _workerThreads
Definition
MapUpdater.h:53
MapUpdater::_lock
std::mutex _lock
Definition
MapUpdater.h:56
MapUpdater::~MapUpdater
~MapUpdater()
Definition
MapUpdater.h:35
MapUpdater::pending_requests
size_t pending_requests
Definition
MapUpdater.h:58
MapUpdater::MapUpdater
MapUpdater()
Definition
MapUpdater.h:34
MapUpdater::_cancelationToken
std::atomic< bool > _cancelationToken
Definition
MapUpdater.h:54
MapUpdater::_queue
ProducerConsumerQueue< MapUpdateRequest * > _queue
Definition
MapUpdater.h:51
MapUpdater::_condition
std::condition_variable _condition
Definition
MapUpdater.h:57
Map
Definition
Map.h:281
ProducerConsumerQueue
Definition
ProducerConsumerQueue.h:29
server
game
Maps
MapUpdater.h
Generated on Sun May 10 2026 02:30:17 for TrinityCore by
1.9.8