2003-04-09 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / observer.c
index c331112951e66461b9eea1708d573b8fff4bde31..6815d0f9c833093464919ae3dbc7ca31cfbea96e 100644 (file)
@@ -95,9 +95,9 @@ xfree_observer_list_node (struct observer_list *node)
   xfree (node);
 }
 
-/* Attach the callback NOTIFY to a subject represented by its list
-   of observers LIST.  The DATA is also stored, in order for the subject
-   to provide it back to the observer during a notification.  */
+/* Attach the callback NOTIFY to a SUBJECT.  The DATA is also stored,
+   in order for the subject to provide it back to the observer during
+   a notification.  */
 
 static struct observer *
 generic_observer_attach (struct observer_list **subject,
@@ -114,10 +114,9 @@ generic_observer_attach (struct observer_list **subject,
   return observer_list->observer;
 }
 
-/* Remove the given OBSERVER from the list of observers that need
-   to be notified by the subject represented by its LIST of observers.
-   Once detached, OBSERVER should no longer be used, as it is no longer
-   valid.  */
+/* Remove the given OBSERVER from the SUBJECT.  Once detached, OBSERVER
+   should no longer be used, as it is no longer valid.  */
+
 static void
 generic_observer_detach (struct observer_list **subject,
                         const struct observer *observer)
@@ -145,9 +144,8 @@ generic_observer_detach (struct observer_list **subject,
   warning ("Failed to detach observer");
 }
 
-/* Send a notification to all the observers of a subject represented by
-   its LIST of observers.  ARGS is passed to all observers as an argument
-   to the notification callback.  */
+/* Send a notification to all the observers of SUBJECT.  ARGS is passed to
+   all observers as an argument to the notification callback.  */
 
 static void
 generic_observer_notify (struct observer_list *subject, const void *args)
@@ -192,3 +190,33 @@ observer_notify_normal_stop (void)
 {
   generic_observer_notify (normal_stop_subject, NULL);
 }
+
+/* The following code is only used to unit-test the observers from
+   our testsuite.  DO NOT USE IT within observer.c!  */
+
+/* Since this code will not be used within GDB, it will trigger
+   a warning if we decide to compile with -Wunused-function.
+   This is ok for now.  (brobecker 2003-03-18)  */
+static int observer_test_first_observer = 0;
+static int observer_test_second_observer = 0;
+static int observer_test_third_observer = 0;
+
+static void
+observer_test_first_notification_function (void)
+{
+  observer_test_first_observer++;
+}
+
+static void
+observer_test_second_notification_function (void)
+{
+  observer_test_second_observer++;
+}
+
+static void
+observer_test_third_notification_function (void)
+{
+  observer_test_third_observer++;
+}
+
This page took 0.024587 seconds and 4 git commands to generate.