File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,11 @@ namespace Concurrency {
206206 ENTROPY_ASSERT (mainThreadSelectingCount == 0 , " WorkContractGroup destroyed with threads still in selectForMainThreadExecution" );
207207
208208 // Then notify the concurrency provider to remove us from active groups
209- if (_concurrencyProvider) {
210- _concurrencyProvider->notifyGroupDestroyed (this );
209+ {
210+ std::unique_lock<std::shared_mutex> lock (_concurrencyProviderMutex);
211+ if (_concurrencyProvider) {
212+ _concurrencyProvider->notifyGroupDestroyed (this );
213+ }
211214 }
212215 }
213216
@@ -293,8 +296,11 @@ namespace Concurrency {
293296 }
294297
295298 // Notify concurrency provider if set
296- if (_concurrencyProvider) {
297- _concurrencyProvider->notifyWorkAvailable (this );
299+ {
300+ std::shared_lock<std::shared_mutex> lock (_concurrencyProviderMutex);
301+ if (_concurrencyProvider) {
302+ _concurrencyProvider->notifyWorkAvailable (this );
303+ }
298304 }
299305
300306 return ScheduleResult::Scheduled;
@@ -761,6 +767,7 @@ namespace Concurrency {
761767 }
762768
763769 void WorkContractGroup::setConcurrencyProvider (IConcurrencyProvider* provider) {
770+ std::unique_lock<std::shared_mutex> lock (_concurrencyProviderMutex);
764771 _concurrencyProvider = provider;
765772 }
766773
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ namespace Concurrency {
146146
147147 // Concurrency provider support
148148 IConcurrencyProvider* _concurrencyProvider = nullptr ; // /< Work notification provider
149+ mutable std::shared_mutex _concurrencyProviderMutex; // /< Protects provider during setup/teardown (COLD PATH ONLY)
149150 std::list<std::function<void ()>> _onCapacityAvailableCallbacks; // /< Capacity callbacks
150151 mutable std::mutex _callbackMutex; // /< Protects callback list
151152
You can’t perform that action at this time.
0 commit comments