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 "
ProducerConsumerQueue.h
"
23
#include <condition_variable>
24
#include <mutex>
25
#include <thread>
26
#include <vector>
27
28
class
MapUpdateRequest
;
29
class
Map
;
30
31
class
TC_GAME_API
MapUpdater
32
{
33
public
:
34
35
MapUpdater
() : _cancelationToken(false), pending_requests(0) {}
36
~MapUpdater
() { }
37
38
friend
class
MapUpdateRequest
;
39
40
void
schedule_update(
Map
& map,
uint32
diff);
41
42
void
wait();
43
44
void
activate(
size_t
num_threads);
45
46
void
deactivate();
47
48
bool
activated()
const
;
49
50
private
:
51
52
ProducerConsumerQueue<MapUpdateRequest*>
_queue
;
53
54
std::vector<std::thread>
_workerThreads
;
55
std::atomic<bool>
_cancelationToken
;
56
57
std::mutex
_lock
;
58
std::condition_variable
_condition
;
59
size_t
pending_requests
;
60
61
void
update_finished();
62
63
void
WorkerThread();
64
};
65
66
#endif
//_MAP_UPDATER_H_INCLUDED
Define.h
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:129
uint32
uint32_t uint32
Definition
Define.h:154
ProducerConsumerQueue.h
MapUpdateRequest
Definition
MapUpdater.cpp:24
MapUpdater
Definition
MapUpdater.h:32
MapUpdater::_workerThreads
std::vector< std::thread > _workerThreads
Definition
MapUpdater.h:54
MapUpdater::_lock
std::mutex _lock
Definition
MapUpdater.h:57
MapUpdater::~MapUpdater
~MapUpdater()
Definition
MapUpdater.h:36
MapUpdater::pending_requests
size_t pending_requests
Definition
MapUpdater.h:59
MapUpdater::MapUpdater
MapUpdater()
Definition
MapUpdater.h:35
MapUpdater::_cancelationToken
std::atomic< bool > _cancelationToken
Definition
MapUpdater.h:55
MapUpdater::_queue
ProducerConsumerQueue< MapUpdateRequest * > _queue
Definition
MapUpdater.h:52
MapUpdater::_condition
std::condition_variable _condition
Definition
MapUpdater.h:58
Map
Definition
Map.h:225
ProducerConsumerQueue
Definition
ProducerConsumerQueue.h:29
server
game
Maps
MapUpdater.h
Generated on Sun May 10 2026 02:09:00 for TrinityCore by
1.9.8