Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using dispatch_get_current_queue. #29075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading