Skip to content

Commit

Permalink
Stop using dispatch_get_current_queue. (#29075)
Browse files Browse the repository at this point in the history
This function is deprecated.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Dec 18, 2023
1 parent 6492993 commit 1396246
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 15 additions & 1 deletion src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,23 @@ bool PlatformManagerImpl::_IsChipStackLockedByCurrentThread() const
};
#endif

static int sPlatformManagerKey; // We use pointer to this as key.

dispatch_queue_t PlatformManagerImpl::GetWorkQueue()
{
if (mWorkQueue == nullptr)
{
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
dispatch_suspend(mWorkQueue);
dispatch_queue_set_specific(mWorkQueue, &sPlatformManagerKey, this, nullptr);
mIsWorkQueueSuspended = true;
}
return mWorkQueue;
}

bool PlatformManagerImpl::IsWorkQueueCurrentQueue() const
{
return dispatch_get_current_queue() == mWorkQueue;
return dispatch_get_specific(&sPlatformManagerKey) == this;
}

CHIP_ERROR PlatformManagerImpl::StartBleScan(BleScannerDelegate * delegate)
Expand Down
12 changes: 1 addition & 11 deletions src/platform/Darwin/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
public:
// ===== Platform-specific members that may be accessed directly by the application.

dispatch_queue_t GetWorkQueue()
{
if (mWorkQueue == nullptr)
{
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
dispatch_suspend(mWorkQueue);
mIsWorkQueueSuspended = true;
}
return mWorkQueue;
}

dispatch_queue_t GetWorkQueue();
bool IsWorkQueueCurrentQueue() const;

CHIP_ERROR StartBleScan(BleScannerDelegate * delegate = nullptr);
Expand Down

0 comments on commit 1396246

Please sign in to comment.