fix vs run bug

This commit is contained in:
sunsuodong 2021-11-15 19:56:06 -08:00
parent 50bbdfef17
commit 4c5732c642
3 changed files with 13 additions and 5 deletions

View File

@ -121,7 +121,7 @@ class MS_API Status {
inline std::string GetErrDescription() const;
inline std::string SetErrDescription(const std::string &err_description);
friend std::ostream &operator<<(std::ostream &os, const Status &s);
MS_API friend std::ostream &operator<<(std::ostream &os, const Status &s);
bool operator==(const Status &other) const;
bool operator==(enum StatusCode other_code) const;

View File

@ -205,11 +205,7 @@ class ActorBase {
AID id;
std::map<std::string, ActorFunction> actionFunctions;
#ifdef _MSC_VER
std::recursive_mutex waiterLock;
#else
std::mutex waiterLock;
#endif
std::string msgRecords[MAX_ACTOR_RECORD_SIZE];
uint32_t recordNextPoint = 0;

View File

@ -40,8 +40,20 @@ void ActorBase::Await() {
// lock here or at spawn(). and unlock here or at worker(). wait for the worker to finish.
MS_LOG(DEBUG) << "ACTOR is waiting for terminate to finish. a=" << actorName.c_str();
#ifdef _MSC_VER
#define TRY_LOCK_INTERVAL 10
while (true) {
if (waiterLock.try_lock()) {
waiterLock.unlock();
break;
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(TRY_LOCK_INTERVAL));
}
}
#else
waiterLock.lock();
waiterLock.unlock();
#endif
// mailbox's hook may hold the actor reference, we need explicitly free the mailbox to avoid the memory leak. the
// details can refer to the comments in ActorMgr::Spawn