]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[event-loop] Add ply_event_loop_get_default ()
authorRay Strode <rstrode@redhat.com>
Thu, 27 Aug 2009 05:26:55 +0000 (01:26 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 28 Sep 2009 15:23:35 +0000 (11:23 -0400)
The event loop is used all through out the code
for many different things.  In order to use it
in all those various bits of code, it's getting
passed around a lot.  This adds a lot of complexity
to the code.

The event loop should probably be a standard
resource that all parts of the code have free access
to in the same vein as the logging apis.

This commit adds a new function
ply_event_loop_get_default () and makes main use it
and pass it along.

Subsequent commits may clean up all the places that
take an event loop to just use this instead.

src/libply/ply-event-loop.c
src/libply/ply-event-loop.h
src/main.c

index 2c03a528eb3ac34f6a989a453999b1cda250d99d..33bd52c7e7431600c3106cad14eab39ed7464251 100644 (file)
@@ -489,6 +489,17 @@ ply_event_loop_new (void)
   return loop;
 }
 
+ply_event_loop_t *
+ply_event_loop_get_default (void)
+{
+  static ply_event_loop_t *loop = NULL;
+
+  if (loop == NULL)
+    loop = ply_event_loop_new ();
+
+  return loop;
+}
+
 static void
 ply_event_loop_free_exit_closures (ply_event_loop_t *loop)
 {
index 98b9cd17996e6bdceb545effaec68bf978579b37..ae29d2854d6a2556a4f07af78ac5b10ca733b469 100644 (file)
@@ -48,6 +48,7 @@ typedef void (* ply_event_loop_timeout_handler_t) (void             *user_data,
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
 ply_event_loop_t *ply_event_loop_new (void);
 void ply_event_loop_free (ply_event_loop_t *loop);
+ply_event_loop_t *ply_event_loop_get_default (void);
 ply_fd_watch_t *ply_event_loop_watch_fd (ply_event_loop_t *loop,
                                          int               fd,
                                          ply_event_loop_fd_status_t status,
index a77c45b6d3a28ebc92d286cef31a425944605aa8..3b40afabd40e6136044a4724f18cf8b58353478d 100644 (file)
@@ -1359,7 +1359,7 @@ main (int    argc,
 
   state.command_parser = ply_command_parser_new ("plymouthd", "Boot splash control server");
 
-  state.loop = ply_event_loop_new ();
+  state.loop = ply_event_loop_get_default ();
 
   ply_command_parser_add_options (state.command_parser,
                                   "help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG,
@@ -1526,9 +1526,6 @@ main (int    argc,
   ply_buffer_free (state.boot_buffer);
   ply_progress_free (state.progress);
 
-  ply_trace ("freeing event loop");
-  ply_event_loop_free (state.loop);
-
   ply_trace ("exiting with code %d", exit_code);
   
   if (debug_buffer != NULL)