Post

Replies

Boosts

Views

Activity

Reply to Bluetooth: prohibiting or detecting unwanted pairing request alert on connect
It's probably related to the "Just Works" pairing method that DOESN'T happen in those cases I am seeing the alert. Got some heavy-wight workaround idea sketch: split the app into two with the second one being background only process. Specify CBConnectPeripheralOptionNotifyOnConnectionKey / CBConnectPeripheralOptionNotifyOnDisconnectionKey, CBConnectPeripheralOptionNotifyOnNotificationKey keys being false and make the "connect" call from there. Then somehow (XPC?) communicate data back to the main app. There must be an easier way!
Mar ’24
Reply to pthread -> NSThread
I was thinking of setting up a signal handler that does Thread.current and assigns the result somewhere (e.g. to a global variable). And then pthread_kill(...) to invoke that signal handler on the thread in question. Do you think this won't work? All the mentioned API's included signal and pthread_kill seem to be supported.
Topic: App & System Services SubTopic: General Tags:
Mar ’24
Reply to Right way to call `host_processors`
I see. Is there a path that doesn't involve privilege escalation? I am thinking of using task_threads + thread_info (with THREAD_BASIC_INFO to get cpu_usage) and somehow determine which processor/core the thread is currently assigned to (†) and then accumulate cpu usages per processor/core. This will only account for threads in the current app but for my purposes this would be enough. (†) - pthread_cpu_number_np doesn't return sensible results for me.
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’24
Reply to DispatchQueue.count > thread.count case
Let me try: let queues = (0 ..< 200).map { i in DispatchQueue(label: "queue-\(i)", serial or concurrent) } queues.forEach { queue in queue.async { while true { // doing something lengthy here is Thread.current unique? In other words was a dedicated thread allocated for this queue? or could a single thread serve several queues? } } } In my tests so far a unique thread is allocated per queue.
Apr ’24
Reply to `getifaddrs` "struct ifa_data"
Right... I'm still curious though how to properly read this specific part of the documentation: For all other address families, it contains a pointer to the struct ifa_data (as defined in include file <net/if.h>) which contains per-address interface statistics. as I do not see "struct ifa_data" anywhere...
Apr ’24
Reply to SwiftUI NavigationView force "both panels side by side" split behaviour
No, that doesn't work: the side panel slides and partially obscures the main panel. For the record: the newer NavigationSplitView + navigationSplitViewStyle(.balanced) does work correctly on my plus sized device.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Bluetooth: prohibiting or detecting unwanted pairing request alert on connect
It's probably related to the "Just Works" pairing method that DOESN'T happen in those cases I am seeing the alert. Got some heavy-wight workaround idea sketch: split the app into two with the second one being background only process. Specify CBConnectPeripheralOptionNotifyOnConnectionKey / CBConnectPeripheralOptionNotifyOnDisconnectionKey, CBConnectPeripheralOptionNotifyOnNotificationKey keys being false and make the "connect" call from there. Then somehow (XPC?) communicate data back to the main app. There must be an easier way!
Replies
Boosts
Views
Activity
Mar ’24
Reply to CoreBluetooth: txPowerLevel + rssi = distance?
This works reasonably well. However, is there a better approach? The two different devices with the same txPowerLevel could have different RSSI at 1 meter values (besides txPowerLevel is optional).
Replies
Boosts
Views
Activity
Mar ’24
Reply to pthread -> NSThread
I was thinking of setting up a signal handler that does Thread.current and assigns the result somewhere (e.g. to a global variable). And then pthread_kill(...) to invoke that signal handler on the thread in question. Do you think this won't work? All the mentioned API's included signal and pthread_kill seem to be supported.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to pthread -> NSThread
This is not safe I see, thank you.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Bluetooth: prohibiting or detecting unwanted pairing request alert on connect
Anyone knows?
Replies
Boosts
Views
Activity
Mar ’24
Reply to Obtaining CPU usage by process
What was the best approach at the end of the day? (for macOS / iOS + appstore)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to pthread -> NSThread
Basically I wanted to have the (short) thread numbers compatible with those shown by Xcode's CPU panel. I can get the thread number from NSThread already, but not from a pthread_t.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Right way to call `host_processors`
What’s you’re high-level goal here? Why do you intend to do with these processor control ports when you get them? I want to get the CPU usage per processor / core, similar to Activity Monitor's "CPU Usage" window.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Right way to call `host_processors`
I see. Is there a path that doesn't involve privilege escalation? I am thinking of using task_threads + thread_info (with THREAD_BASIC_INFO to get cpu_usage) and somehow determine which processor/core the thread is currently assigned to (†) and then accumulate cpu usages per processor/core. This will only account for threads in the current app but for my purposes this would be enough. (†) - pthread_cpu_number_np doesn't return sensible results for me.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to DispatchQueue.count > thread.count case
Let me try: let queues = (0 ..< 200).map { i in DispatchQueue(label: "queue-\(i)", serial or concurrent) } queues.forEach { queue in queue.async { while true { // doing something lengthy here is Thread.current unique? In other words was a dedicated thread allocated for this queue? or could a single thread serve several queues? } } } In my tests so far a unique thread is allocated per queue.
Replies
Boosts
Views
Activity
Apr ’24
Reply to DispatchQueue.count > thread.count case
My fear was that while one queue's work item is still in progress the associated thread could be used somehow to run the other queue's work item.
Replies
Boosts
Views
Activity
Apr ’24
Reply to `getifaddrs` "struct ifa_data"
Right... I'm still curious though how to properly read this specific part of the documentation: For all other address families, it contains a pointer to the struct ifa_data (as defined in include file <net/if.h>) which contains per-address interface statistics. as I do not see "struct ifa_data" anywhere...
Replies
Boosts
Views
Activity
Apr ’24
Reply to Documentation for `DispatchQueue.concurrentPerform` confusingly references the 'target queue' over which callers have no direct control.
concurrentPerform is a class method that has no queue parameter, so the wording in the documentation about "If the target queue is a concurrent queue..." is bogus, not just unclear.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to Downloading a folder from opensource.apple.com
Thank you! So there was no way indeed to download folders in there?! 🤣
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’24