0

While I was browsing through the iOS 7 runtime headers, something caught my eye. In the MCNearbyServiceAdvertiser class, part of the Multipeer Connectivity framework, a property called syncQueue is and multiple methods prefixed with sync are defined. Some of the methods both exist in a prefixed and non-prefixed version, such as startAdvertisingPeer and syncStartAdvertisingPeer.

My question is, what would be the purpose of both this property and these prefixed methods, and how are they combined?

(edit: removed the remark that the queue is serial as pointed out by CouchDeveloper, since we cannot know this)

4

1 回答 1

1

如您所知,实现是私有的。

拥有一个名为 的调度队列syncQueue可能并不意味着该队列是一个串行队列。它也可能是一个并发队列。

我们只能猜测startAdvertisingPeer“前缀”版本syncStartAdvertisingPeer可能意味着什么。

例如,为了满足内部先决条件,startAdvertisingPeer 可能会假设它总是从syncQueue之外的执行上下文中调用。这样,它可以通过调用同步调度到syncQueue,syncStartAdvertisingPeer而不会陷入死锁。另一方面,syncStartAdvertisingPeer将始终假设在syncQueue上执行,这样可以保证并发性。

但是,如前所述,我们不知道实际的细节——这只是一个粗略的猜测。通常,您应该阅读文档 - 而不是一些私有标题详细信息,以便在您的脑海中描绘出此类可能如何工作。

于 2013-12-23T15:24:19.687 回答