[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheduling functions to be run all the time in runloop
From: |
Dr. H. Nikolaus Schaller |
Subject: |
Re: Scheduling functions to be run all the time in runloop |
Date: |
Mon, 9 Jul 2012 22:52:37 +0200 |
Am 09.07.2012 um 22:29 schrieb Ivan Vučica:
>
> On 9. 7. 2012., at 22:11, Dr. H. Nikolaus Schaller wrote:
>
>> Am 09.07.2012 um 21:58 schrieb Ivan Vučica:
>>
>>> Hi,
>>>
>>> for Core Animation's implicit animations to work properly, I need to
>>> schedule creation and flushing of implicit CATransaction whenever event
>>> processing is entered, and whenever the runloop code is entered again. This
>>> can be either a C function or an Objective-C method, but I need these two
>>> pieces of code to run each and every time runloop calls user code and
>>> whenever user code is done running.
>>>
>>> Note, I'm not trying to accomplish continuous calling of these methods
>>> (that's trivial using e.g. timers); instead, I need these methods to be
>>> called, for example, when user chooses a menu item or clicks on a button.
>>>
>>> What's the easiest way to accomplish this?
>>
>> Since this is similar to the displayIfNeeded-mechanism, I think you have to
>> add it to -[NSApplication run] or -[NSApplication runModalSession:]. Maybe
>> it could also be added to -[NSApplication updateWindows].
>>
>> But if you need to have to do this in any tracking loop (usually in
>> mouseDown:), you should add it to -[NSApplication nextEventMatchingMask:...].
>>
>> Please don't think you can add it to NSRunLoop since this is Base and not
>> GUI...
>>
>> If all this does not work, you could try the applicationWillUpdate /
>> applicationDidUpdate notifications.
>
> Please note that Core Animation is not in GUI either :-)
Yes, but you can't guarantee that there is a runloop at all if you don't have
GUI... And I don't know if CA is useful if you don't have any GUI.
> Is there no API in NSRunLoop for scheduling additional functions to be run in
> the situations I described that would be available to applications?
Yes, there are some idle and other hooks. Maybe you can also achieve what you
intend by NSNotificationQueue.
But it is not clear to me what you really want to achieve. On one hand it looks
like you want to intercept user events. On the other hand I assume that it is
more related to keeping the display updated in time (flushing).
And you mention "every time runloop calls user code and whenever user code is
done running". Can you please better specify (examples) what "user code" means
for you? Are notifications "user code"? Are timers "user code"? Are file
handle/socket events "user code"? All these are handled by the runloop, and GUI
events are only a variant of them.
BR,
Nikolaus
- Scheduling functions to be run all the time in runloop, Ivan Vučica, 2012/07/09
- Re: Scheduling functions to be run all the time in runloop, Dr . H . Nikolaus Schaller, 2012/07/09
- Re: Scheduling functions to be run all the time in runloop, Ivan Vučica, 2012/07/09
- Re: Scheduling functions to be run all the time in runloop,
Dr. H. Nikolaus Schaller <=
- Re: Scheduling functions to be run all the time in runloop, Dr. H. Nikolaus Schaller, 2012/07/09
- Message not available
- Re: Scheduling functions to be run all the time in runloop, Dr. H. Nikolaus Schaller, 2012/07/10
- Re: Scheduling functions to be run all the time in runloop, Richard Frith-Macdonald, 2012/07/10
- Re: Scheduling functions to be run all the time in runloop, Dr. H. Nikolaus Schaller, 2012/07/10
- Re: Scheduling functions to be run all the time in runloop, Richard Frith-Macdonald, 2012/07/10
Re: Scheduling functions to be run all the time in runloop, Richard Frith-Macdonald, 2012/07/09