Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Core/AuctionHouse): Rework auctionhouse search threading #20830

Merged
merged 23 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02c586e
Initial work on AH threading rewrite - WIP
Takenbacon Nov 19, 2024
e8ff193
Couple changes based on feedback
Takenbacon Nov 27, 2024
e23e31a
Restore original auctionEntry item handling
Takenbacon Nov 27, 2024
d3e230c
Handle SMSG_AUCTION_OWNER_LIST_RESULT, SMSG_AUCTION_BIDDER_LIST_RESULT
Takenbacon Dec 2, 2024
77cd878
Add worker thread config
Takenbacon Dec 2, 2024
61b83b8
Move timer updating of AuctionHouseMgr to fix delay in thread responses
Takenbacon Dec 3, 2024
e6aaca9
Fix mistake with usable flag optional
Takenbacon Dec 3, 2024
e644c70
Fix restoring bidder info on realm restart
Takenbacon Dec 3, 2024
d2fac12
Merge branch 'azerothcore:master' into ah_threading
Takenbacon Dec 3, 2024
04cb0de
Fix GCC compile warning
Takenbacon Dec 3, 2024
1c52e6b
Missing timer include
Takenbacon Dec 3, 2024
e1cd9f7
Still working on making the build tools happy...
Takenbacon Dec 3, 2024
06a7acc
Fix gcc enumeration warning
Takenbacon Dec 3, 2024
ac5a73e
Add back GetAuctionOutBid helper to fix ahbot compatibility
Takenbacon Dec 3, 2024
c7f2b8c
Modify how we stop the worker threads to make the dry run build scrip…
Takenbacon Dec 3, 2024
6cb4d9c
Scope AH update call for proper metrics
Takenbacon Dec 4, 2024
ed83ecd
Remove useless preexisting micro-optimization
Takenbacon Dec 4, 2024
f2e9608
Small codestyle change
Takenbacon Dec 4, 2024
2a51d56
Add auction list opcodes to antidos system
Takenbacon Dec 4, 2024
dc8b75f
Merge branch 'master' into ah_threading
Takenbacon Dec 12, 2024
c921b61
oops lol
Takenbacon Dec 12, 2024
07746fc
Merge branch 'master' into ah_threading
Takenbacon Dec 18, 2024
85e0903
Add comment for MAX_GETALL_RETURN
Takenbacon Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4280,11 +4280,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
Loading