WebObjects 5.4.2

com.webobjects.foundation
Class NSDelayedCallbackCenter

java.lang.Object
  extended by com.webobjects.foundation.NSDelayedCallbackCenter

public class NSDelayedCallbackCenter
extends Object

An NSDelayedCallbackCenter object (also called a delayed callback center) provides a way to guarantee that particular methods are invoked after an event has ended. It allows you to postpone or schedule the execution of certain tasks for a point in time, for example because they can't be performed earlier, or because then they will have to be performed only once (combined effect). Selectors are registered with the delayed callback center in an internal list. The center, in turn, invokes them when the event ends. In WebObjects, this happens at the end of the current request-response cycle.

When a selector is registered, a priority is specified, which determines the order in which it is invoked relative to the other selectors. The selectors are invoked in order of ascending priority. To register a selector with the delayed callback center, use performSelector. To cancel it before the event ends, use cancelPerformSelector.

The event loop invokes eventEnded to indicate that the current event has ended. The eventEnded method invokes the queued selectors.

Each task has a default delayed callback center that you access with the defaultCenter static method.

See Also:
NSDelayedCallbackCenter.performSelector(NSSelector,Object,Object,int), NSDelayedCallbackCenter.cancelPerformSelector(NSSelector,Object,Object), NSDelayedCallbackCenter.eventEnded(), NSDelayedCallbackCenter.defaultCenter()

Method Summary
 void cancelPerformSelector(NSSelector selector, Object target, Object argument)
          Removes the specified selector for the specified target object and argument from the list of registered selectors.
static NSDelayedCallbackCenter defaultCenter()
          Returns the current default center for the current request-response cycle.
 void eventEnded()
          Invokes the registered selectors in order of ascending priority.
 void performSelector(NSSelector selector, Object target, Object argument, int order)
          Registers selector to be invoked on target with the specified argument and order (priority).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

defaultCenter

public static NSDelayedCallbackCenter defaultCenter()
Returns the current default center for the current request-response cycle. This is the current delayed callback center (NSDelayedCallbackCenter) for the calling thread.

Returns:
the current default center

performSelector

public void performSelector(NSSelector selector,
                            Object target,
                            Object argument,
                            int order)
Registers selector to be invoked on target with the specified argument and order (priority). When the current event ends, the registered selectors are invoked in order of ascending priority.

Parameters:
selector - The selector to be registered
target - The target object on which the selector will be called
argument - The argument with which the selector will be called on the target object
order - The priority (order) of the invocation

cancelPerformSelector

public void cancelPerformSelector(NSSelector selector,
                                  Object target,
                                  Object argument)
Removes the specified selector for the specified target object and argument from the list of registered selectors. Only this specific combination of selector, target and argument will be removed.

Parameters:
selector - The selector to be cancelled (to be removed)
target - The target object for which the selector was registered
argument - The argument object for which the selector was registered

eventEnded

public void eventEnded()
Invokes the registered selectors in order of ascending priority. The event loop should invoke this method when the current event ends.


Last updated June 2008

Copyright © 2000-2008 Apple Inc.