mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sourcekit] Use a shared_ptr for the NotificationCenter
When the server shuts down we may still have outstanding async work that can attempt to trigger a notification, so use a shared_ptr + weak_ptr instead of unique_ptr + unowned references.
This commit is contained in:
@@ -596,7 +596,7 @@ class SwiftDocumentSemanticInfo :
|
||||
|
||||
const std::string Filename;
|
||||
SwiftASTManager &ASTMgr;
|
||||
NotificationCenter &NotificationCtr;
|
||||
std::weak_ptr<NotificationCenter> NotificationCtr;
|
||||
ThreadSafeRefCntPtr<SwiftInvocation> InvokRef;
|
||||
std::string CompilerArgsError;
|
||||
|
||||
@@ -873,7 +873,8 @@ void SwiftDocumentSemanticInfo::updateSemanticInfo(
|
||||
}
|
||||
|
||||
LOG_INFO_FUNC(High, "posted document update notification for: " << Filename);
|
||||
NotificationCtr.postDocumentUpdateNotification(Filename);
|
||||
if (auto notifications = NotificationCtr.lock())
|
||||
notifications->postDocumentUpdateNotification(Filename);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
Reference in New Issue
Block a user