Clarify that run loop watchers are NOT retained, and are responsible for removing themselves from the run loop when they have finished watching for events.

This commit is contained in:
Richard Frith-Macdonald 2021-11-11 10:01:52 +00:00
parent 824fcb8e65
commit b55ee6b0c5
2 changed files with 6 additions and 4 deletions

View file

@ -191,8 +191,9 @@ typedef enum {
/** Adds a watcher to the receiver ... the watcher is used to monitor events /** Adds a watcher to the receiver ... the watcher is used to monitor events
* of the specified type which are associted with the event handle data and * of the specified type which are associted with the event handle data and
* it operates in the specified run loop modes.<br /> * it operates in the specified run loop modes.<br />
* The watcher remains in place until a corresponding call to * The watcher is not retained, but remains in place until a corresponding
* -removeEvent:type:forMode:all: is made. * call to -removeEvent:type:forMode:all: is made. If is the watchers
* responsibility to ensure that it is removed from the run loop safely.
*/ */
- (void) addEvent: (void*)data - (void) addEvent: (void*)data
type: (RunLoopEventType)type type: (RunLoopEventType)type

View file

@ -44,8 +44,9 @@
* watcher is interested in. Its meaning is system dependent. * watcher is interested in. Its meaning is system dependent.
* *
* The 'receiver' is the object which should be told when the event * The 'receiver' is the object which should be told when the event
* occurs. This object is retained so that we know it will continue * occurs. This object is NOT retained so that we can avoid retain
* to exist and can handle a callback. * loops. It is the responsibility of the receiver to invalidate
* the watcher before it is destroyed.
* *
* The 'type' variable indentifies the type of event watched for. * The 'type' variable indentifies the type of event watched for.
* NSRunLoops [-acceptInputForMode: beforeDate: ] method MUST contain * NSRunLoops [-acceptInputForMode: beforeDate: ] method MUST contain