[sourcekit] Make NotificationCenter a strong reference

Addressing review feedback: the notification center does not introduce a
cycle, so no need for weak.
This commit is contained in:
Ben Langmuir
2018-09-25 16:23:24 -07:00
parent f51df32478
commit 2fbe270c6d
2 changed files with 6 additions and 7 deletions

View File

@@ -596,7 +596,7 @@ class SwiftDocumentSemanticInfo :
const std::string Filename;
std::weak_ptr<SwiftASTManager> ASTMgr;
std::weak_ptr<NotificationCenter> NotificationCtr;
std::shared_ptr<NotificationCenter> NotificationCtr;
ThreadSafeRefCntPtr<SwiftInvocation> InvokRef;
std::string CompilerArgsError;
@@ -612,7 +612,7 @@ class SwiftDocumentSemanticInfo :
public:
SwiftDocumentSemanticInfo(StringRef Filename,
std::weak_ptr<SwiftASTManager> ASTMgr,
std::weak_ptr<NotificationCenter> NotificationCtr)
std::shared_ptr<NotificationCenter> NotificationCtr)
: Filename(Filename), ASTMgr(ASTMgr), NotificationCtr(NotificationCtr) {}
SwiftInvocationRef getInvocation() const {
@@ -878,8 +878,7 @@ void SwiftDocumentSemanticInfo::updateSemanticInfo(
}
LOG_INFO_FUNC(High, "posted document update notification for: " << Filename);
if (auto notifications = NotificationCtr.lock())
notifications->postDocumentUpdateNotification(Filename);
NotificationCtr->postDocumentUpdateNotification(Filename);
}
namespace {
@@ -1030,7 +1029,7 @@ void SwiftDocumentSemanticInfo::processLatestSnapshotAsync(
struct SwiftEditorDocument::Implementation {
std::weak_ptr<SwiftASTManager> ASTMgr;
std::weak_ptr<NotificationCenter> NotificationCtr;
std::shared_ptr<NotificationCenter> NotificationCtr;
const std::string FilePath;
EditableTextBufferRef EditableBuffer;