Пересмотр асинхронностей
This commit is contained in:
@@ -13,7 +13,7 @@ namespace LV::Server {
|
||||
|
||||
BinaryResourceManager::BinaryResourceManager(asio::io_context &ioc,
|
||||
std::shared_ptr<ResourceFile> zeroResource)
|
||||
: AsyncObject(ioc), ZeroResource(std::move(zeroResource))
|
||||
: IOC(ioc), ZeroResource(std::move(zeroResource))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ ResourceId_t BinaryResourceManager::getResource_Assets(std::string path) {
|
||||
UpdatedResources.lock_write()->push_back(resId);
|
||||
} else {
|
||||
res->IsLoading = true;
|
||||
co_spawn(checkResource_Assets(resId, iter->second / inDomainPath, res));
|
||||
asio::co_spawn(IOC, checkResource_Assets(resId, iter->second / inDomainPath, res), asio::detached);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
#include <vector>
|
||||
#include <Common/Async.hpp>
|
||||
#include "Abstract.hpp"
|
||||
#include "boost/asio/io_context.hpp"
|
||||
|
||||
|
||||
namespace LV::Server {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class BinaryResourceManager : public AsyncObject {
|
||||
class BinaryResourceManager {
|
||||
asio::io_context &IOC;
|
||||
public:
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,8 +20,10 @@ namespace LV::Server {
|
||||
|
||||
GameServer::~GameServer() {
|
||||
shutdown("on ~GameServer");
|
||||
|
||||
|
||||
|
||||
RunThread.join();
|
||||
WorkDeadline.cancel();
|
||||
UseLock.wait_no_use();
|
||||
LOG.info() << "Сервер уничтожен";
|
||||
}
|
||||
@@ -448,7 +450,7 @@ void GameServer::stepPlayers() {
|
||||
auto lock = External.NewConnectedPlayers.lock_write();
|
||||
|
||||
for(std::unique_ptr<RemoteClient> &client : *lock) {
|
||||
co_spawn(client->run());
|
||||
asio::co_spawn(IOC, client->run(), asio::detached);
|
||||
Game.CECs.push_back(std::make_unique<ContentEventController>(std::move(client)));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace LV::Server {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class GameServer : public AsyncObject {
|
||||
class GameServer {
|
||||
asio::io_context &IOC;
|
||||
TOS::Logger LOG = "GameServer";
|
||||
DestroyLock UseLock;
|
||||
std::thread RunThread;
|
||||
@@ -112,7 +113,7 @@ class GameServer : public AsyncObject {
|
||||
|
||||
public:
|
||||
GameServer(asio::io_context &ioc, fs::path worldPath)
|
||||
: AsyncObject(ioc),
|
||||
: IOC(ioc),
|
||||
Content(ioc, nullptr, nullptr, nullptr)
|
||||
{
|
||||
init(worldPath);
|
||||
|
||||
Reference in New Issue
Block a user