Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess you're filling up the queue (underlying mach port)... </p> <p>You can confirm this using the "scheduling" or "system call" instrument in Instruments. (Create a new blank document, add the instrument, then under <code>File &gt; Record Options...</code> make sure "deferred mode" is checked.) This will show all thread activity in your app (when threads block, when they sleep, when they are activated, and why).</p> <p>I would first try raising the thread priority (cf. <code>man 3 PTHREAD_SCHEDPARAM</code>) of the thread calling <code>CGEventPost</code>. If your thread is blocked on a lower priority thread, the kernel should temporarily elevate the priority of the blocking thread to avoid priority inversion and help your task complete earlier.</p> <p>Overall I think you will have to implement a <strong>2-thread solution</strong>, as below:</p> <p>Create a queue for events you want to post. Post events to this queue from your main thread (or event posting thread), then signal a second thread (an event consumer thread you create) to walk the queue and post any outstanding events with <code>CGEventPost</code>.</p> <p>When <code>CGEventPost</code> blocks, your second event-posting thread will block, but this won't block any other threads. When <code>CGEventPost</code> eventually unblocks, it will consume any outstanding events posted by your event consumer thread and the event consumer thread can resume posting events.</p> <p>Another possibility: can you coallesce events? There are certain types of events (mouse moves?) that you could coallesce into fewer events. You will probably still run into the queue limit of <code>CGEventPost</code> at times, I think the 2-thread approach is probably your best bet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload