Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay so this is a long shot, but you could try implementing something sort of like <code>NSSystemClockDidChangeNotification</code> available in Snow Leopard.</p> <p>So bear with me here, because this is a strange idea and is definitely non-derterministic. But what if you had a watchdog thread running through the duration of your program? This thread would, every n seconds, read the system time and store it. For the sake of argument, let's just make it 5 seconds. So every 5 seconds, it compares the previous reading to the current system time. If there's a "big enough" difference ("big enough" would need to definitely be greater than 5, but not <em>too much</em> greater, to account for the non-determinism of process scheduling and thread prioritization), post a notification that there has been a significant time change. You would need to play around with fuzzing the value that constitutes "big enough" (or small enough, if the clock was reset to an earlier time) for your accuracy needs.</p> <p>I know this is kind of hacky, but barring any other solution, what do you think? Might that, or something like that, solve your issue?</p> <p><strong>Edit</strong></p> <p>Okay so you modified your original question to say that you'd rather not use a watchdog thread because you are new to multithreading. I understand the fear of doing something a bit more advanced than you are comfortable with, but this might end up being the only solution. In that case, you might have a bit of reading to do. =)</p> <p>And yeah, I know that something such as Photoshop pegging the crap out of the processor is a problem. Another (even more complicated) solution would be to, instead of having a watchdog <em>thread</em>, have a separate watchdog <em>process</em> that has top priority so it is a bit more immune to processor pegging. But again, this is getting really complicated.</p> <p><strong>Final Edit</strong></p> <p>I'm going to leave all my other ideas above for completeness' sake, but it seems that using the system's uptime will also be a valid way to deal with this. Since <code>[[NSProcessInfo processInfo] systemUptime]</code> only works in 10.6+, you can just call <code>mach_absolute_time()</code>. To get access to that function, just <code>#include &lt;mach/mach_time.h&gt;</code>. That should be the same value as returned by <code>NSProcessInfo</code>.</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. 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.
 

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