Skip to content

Commit

Permalink
feat(Core/AuctionHouse): Rework auctionhouse search threading (azerot…
Browse files Browse the repository at this point in the history
  • Loading branch information
Takenbacon authored Dec 18, 2024
1 parent e9c8673 commit 4d349e8
Show file tree
Hide file tree
Showing 16 changed files with 1,257 additions and 866 deletions.
60 changes: 0 additions & 60 deletions src/server/apps/worldserver/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "ACSoap.h"
#include "AppenderDB.h"
#include "AsyncAcceptor.h"
#include "AsyncAuctionListing.h"
#include "Banner.h"
#include "BattlegroundMgr.h"
#include "BigNumber.h"
Expand Down Expand Up @@ -112,7 +111,6 @@ void StopDB();
bool LoadRealmInfo(Acore::Asio::IoContext& ioContext);
AsyncAcceptor* StartRaSocketAcceptor(Acore::Asio::IoContext& ioContext);
void ShutdownCLIThread(std::thread* cliThread);
void AuctionListingRunnable();
void WorldUpdateLoop();
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, [[maybe_unused]] std::string& cfg_service);

Expand Down Expand Up @@ -397,15 +395,6 @@ int main(int argc, char** argv)
cliThread.reset(new std::thread(CliThread), &ShutdownCLIThread);
}

// Launch auction listing thread
std::shared_ptr<std::thread> auctionListingThread;
auctionListingThread.reset(new std::thread(AuctionListingRunnable),
[](std::thread* thr)
{
thr->join();
delete thr;
});

WorldUpdateLoop();

// Shutdown starts here
Expand Down Expand Up @@ -713,55 +702,6 @@ bool LoadRealmInfo(Acore::Asio::IoContext& ioContext)
return true;
}

void AuctionListingRunnable()
{
LOG_INFO("server", "Starting up Auction House Listing thread...");

while (!World::IsStopped())
{
Milliseconds diff = AsyncAuctionListingMgr::GetDiff();
AsyncAuctionListingMgr::ResetDiff();

if (!AsyncAuctionListingMgr::GetTempList().empty() || !AsyncAuctionListingMgr::GetList().empty())
{
{
std::lock_guard<std::mutex> guard(AsyncAuctionListingMgr::GetTempLock());

for (auto const& delayEvent: AsyncAuctionListingMgr::GetTempList())
AsyncAuctionListingMgr::GetList().emplace_back(delayEvent);

AsyncAuctionListingMgr::GetTempList().clear();
}

for (auto& itr: AsyncAuctionListingMgr::GetList())
{
if (itr._pickupTimer <= diff)
{
itr._pickupTimer = Milliseconds::zero();
}
else
{
itr._pickupTimer -= diff;
}
}

for (auto itr = AsyncAuctionListingMgr::GetList().begin(); itr != AsyncAuctionListingMgr::GetList().end(); ++itr)
{
if ((*itr)._pickupTimer != Milliseconds::zero())
continue;

if ((*itr).Execute())
AsyncAuctionListingMgr::GetList().erase(itr);

break;
}
}
std::this_thread::sleep_for(1ms);
}

LOG_INFO("server", "Auction House Listing thread exiting without problems.");
}

variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, [[maybe_unused]] std::string& configService)
{
options_description all("Allowed options");
Expand Down
8 changes: 4 additions & 4 deletions src/server/apps/worldserver/worldserver.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4298,11 +4298,11 @@ Event.Announce = 0
###################################################################################################
# AUCTION HOUSE
#
# AuctionHouse.SearchTimeout
# Description: Time (in milliseconds) after which an auction house search is discarded.
# Default: 1000 - (1 second)
# AuctionHouse.WorkerThreads
# Description: Count of auctionhouse searcher worker threads to spawn
# Default: 1

AuctionHouse.SearchTimeout = 1000
AuctionHouse.WorkerThreads = 1

#
# LevelReq.Auction
Expand Down
Loading

0 comments on commit 4d349e8

Please sign in to comment.