mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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:
@@ -114,7 +114,7 @@ public:
|
||||
SourceKit::createSwiftLangSupport,
|
||||
/*dispatchOnMain=*/false);
|
||||
auto localDocUpdState = std::make_shared<DocUpdateMutexState>();
|
||||
Ctx->getNotificationCenter().addDocumentUpdateNotificationReceiver(
|
||||
Ctx->getNotificationCenter()->addDocumentUpdateNotificationReceiver(
|
||||
[localDocUpdState](StringRef docName) {
|
||||
std::unique_lock<std::mutex> lk(localDocUpdState->Mtx);
|
||||
localDocUpdState->HasUpdate = true;
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
}
|
||||
|
||||
void addNotificationReceiver(DocumentUpdateNotificationReceiver Receiver) {
|
||||
Ctx->getNotificationCenter().addDocumentUpdateNotificationReceiver(Receiver);
|
||||
Ctx->getNotificationCenter()->addDocumentUpdateNotificationReceiver(Receiver);
|
||||
}
|
||||
|
||||
bool waitForDocUpdate(bool reset = false) {
|
||||
|
||||
Reference in New Issue
Block a user