[gnio] Make GSocketListener & co more in-line with glib style



commit 084ba9f6f9b5ac59439426de23d0a36b61858622
Author: Alexander Larsson <alexl redhat com>
Date:   Fri May 15 14:25:56 2009 +0200

    Make GSocketListener & co more in-line with glib style
---
 gio/gsocketlistener.c        |    6 +++-
 gio/gsocketlistener.h        |   44 ++++++++++++++++++++++++++++++++++-------
 gio/gsocketoutputstream.c    |    2 +-
 gio/gsocketservice.c         |   24 ++++++++++++++++++----
 gio/gsocketservice.h         |   44 +++++++++++++++++++++++++++++++++++------
 gio/gthreadedsocketservice.c |   24 ++++++++++++++++++++--
 gio/gthreadedsocketservice.h |   38 ++++++++++++++++++++++++++++++-----
 7 files changed, 150 insertions(+), 32 deletions(-)

diff --git a/gio/gsocketlistener.c b/gio/gsocketlistener.c
index 340ac1a..f5cb9c7 100644
--- a/gio/gsocketlistener.c
+++ b/gio/gsocketlistener.c
@@ -1,7 +1,8 @@
-/* GNIO - GLib Network Layer of GIO
+/* GIO - GLib Input, Output and Streaming Library
  *
  * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  * Copyright © 2009 codethink
+ * Copyright © 2009 Red Hat, Inc
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,11 +22,12 @@
  * Authors: Christian Kellner <gicmo gnome org>
  *          Samuel Cormier-Iijima <sciyoshi gmail com>
  *          Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
+#include "config.h"
 #include "gsocketlistener.h"
 
-#include "config.h"
 #include <gio/gsimpleasyncresult.h>
 #include <gio/gcancellable.h>
 #include <gio/gsocketaddress.h>
diff --git a/gio/gsocketlistener.h b/gio/gsocketlistener.h
index 2ce15b1..6f92e56 100644
--- a/gio/gsocketlistener.h
+++ b/gio/gsocketlistener.h
@@ -1,25 +1,36 @@
-/*
+/* GIO - GLib Input, Output and Streaming Library
+ *
  * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  * Copyright © 2009 Codethink Limited
+ * Copyright © 2009 Red Hat, Inc
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; either version 2 of the licence or (at
  * your option) any later version.
  *
- * See the included COPYING file for more information.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
  *
  * Authors: Christian Kellner <gicmo gnome org>
  *          Samuel Cormier-Iijima <sciyoshi gmail com>
  *          Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
 #error "Only <gio/gio.h> can be included directly."
 #endif
 
-#ifndef _gsocketlistener_h_
-#define _gsocketlistener_h_
+#ifndef __G_SOCKET_LISTENER_H__
+#define __G_SOCKET_LISTENER_H__
 
 #include <gio/gsocketconnection.h>
 #include <gio/gsocket.h>
@@ -38,17 +49,34 @@ G_BEGIN_DECLS
 #define G_SOCKET_LISTENER_GET_CLASS(inst)                   (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
                                                              G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
 
+/**
+ * GSocketClient:
+ *
+ * A helper class for network servers to listen for and accept connections.
+ *
+ * Since: 2.22
+ **/
+typedef struct _GSocketListener                             GSocketListener;
 typedef struct _GSocketListenerPrivate                      GSocketListenerPrivate;
 typedef struct _GSocketListenerClass                        GSocketListenerClass;
-typedef struct _GSocketListener                             GSocketListener;
 
+/**
+ * GSocketListenerClass:
+ * @changed: virtual method called when the set of socket listened to changes
+ **/
 struct _GSocketListenerClass
 {
   GObjectClass parent_class;
 
   void (* changed) (GSocketListener *listener);
 
-  gpointer padding[6];
+  /* Padding for future expansion */
+  void (*_g_reserved1) (void);
+  void (*_g_reserved2) (void);
+  void (*_g_reserved3) (void);
+  void (*_g_reserved4) (void);
+  void (*_g_reserved5) (void);
+  void (*_g_reserved6) (void);
 };
 
 struct _GSocketListener
@@ -57,7 +85,7 @@ struct _GSocketListener
   GSocketListenerPrivate *priv;
 };
 
-GType                   g_socket_listener_get_type                      (void);
+GType                   g_socket_listener_get_type                      (void) G_GNUC_CONST;
 
 GSocketListener *       g_socket_listener_new                           (void);
 
@@ -112,4 +140,4 @@ void                    g_socket_listener_close                         (GSocket
 
 G_END_DECLS
 
-#endif /* _gsocketlistener_h_ */
+#endif /* __G_SOCKET_LISTENER_H__ */
diff --git a/gio/gsocketoutputstream.c b/gio/gsocketoutputstream.c
index dd36793..a888bb7 100644
--- a/gio/gsocketoutputstream.c
+++ b/gio/gsocketoutputstream.c
@@ -1,4 +1,4 @@
-/* GNIO - GLib Network Layer of GIO
+/*  GIO - GLib Input, Output and Streaming Library
  *
  * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  *           © 2009 codethink
diff --git a/gio/gsocketservice.c b/gio/gsocketservice.c
index f4f20d8..0a89577 100644
--- a/gio/gsocketservice.c
+++ b/gio/gsocketservice.c
@@ -1,12 +1,25 @@
-/*
+/* GIO - GLib Input, Output and Streaming Library
+ *
  * Copyright © 2009 Codethink Limited
+ * Copyright © 2009 Red Hat, Inc
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; either version 2 of the licence or (at
  * your option) any later version.
  *
- * See the included COPYING file for more information.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
 /**
@@ -19,9 +32,9 @@
  * provided to the network or over local sockets.  When a new
  * connection is made to the service the ::incoming signal is emitted.
  *
- * A #GSocketService doesn't do the listening for itself.  At least
- * one #GSocketListener must be created and added to the service for
- * connections to be accepted from.
+ * A #GSocketService is a subclass of #GSocketListener and you need
+ * to add the addresses you want to accept connections on to the
+ * with the #GSocketListener APIs.
  *
  * There are two options for implementing a network service based on
  * #GSocketService.  The first is to create the service using
@@ -35,6 +48,7 @@
  * blocking code then see #GThreadedSocketService.
  */
 
+#include "config.h"
 #include "gsocketservice.h"
 
 #include "gnio-marshal.h"
diff --git a/gio/gsocketservice.h b/gio/gsocketservice.h
index 8836904..610022f 100644
--- a/gio/gsocketservice.h
+++ b/gio/gsocketservice.h
@@ -1,22 +1,33 @@
-/*
+/* GIO - GLib Input, Output and Streaming Library
+ *
  * Copyright © 2009 Codethink Limited
+ * Copyright © 2009 Red Hat, Inc
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; either version 2 of the licence or (at
  * your option) any later version.
  *
- * See the included COPYING file for more information.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
  *
  * Authors: Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
 #error "Only <gio/gio.h> can be included directly."
 #endif
 
-#ifndef _gsocketservice_h_
-#define _gsocketservice_h_
+#ifndef __G_SOCKET_SERVICE_H__
+#define __G_SOCKET_SERVICE_H__
 
 #include <gio/gsocketlistener.h>
 
@@ -34,10 +45,22 @@ G_BEGIN_DECLS
 #define G_SOCKET_SERVICE_GET_CLASS(inst)                    (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
                                                              G_TYPE_SOCKET_SERVICE, GSocketServiceClass))
 
+/**
+ * GSocketService:
+ *
+ * A helper class for handling accepting incomming connections in the
+ * glib mainloop.
+ *
+ * Since: 2.22
+ **/
+typedef struct _GSocketService                              GSocketService;
 typedef struct _GSocketServicePrivate                       GSocketServicePrivate;
 typedef struct _GSocketServiceClass                         GSocketServiceClass;
-typedef struct _GSocketService                              GSocketService;
 
+/**
+ * GSocketServiceClass:
+ * @incomming: signal emitted when new connections are accepted
+ **/
 struct _GSocketServiceClass
 {
   GSocketListenerClass parent_class;
@@ -45,7 +68,14 @@ struct _GSocketServiceClass
   gboolean (* incoming) (GSocketService    *service,
                          GSocketConnection *connection,
 			 GObject           *source_object);
-  gpointer padding[6];
+
+  /* Padding for future expansion */
+  void (*_g_reserved1) (void);
+  void (*_g_reserved2) (void);
+  void (*_g_reserved3) (void);
+  void (*_g_reserved4) (void);
+  void (*_g_reserved5) (void);
+  void (*_g_reserved6) (void);
 };
 
 struct _GSocketService
@@ -64,4 +94,4 @@ gboolean        g_socket_service_is_active (GSocketService *service);
 
 G_END_DECLS
 
-#endif /* _gsocketservice_h_ */
+#endif /* __G_SOCKET_SERVICE_H__ */
diff --git a/gio/gthreadedsocketservice.c b/gio/gthreadedsocketservice.c
index 990a0f5..6aac270 100644
--- a/gio/gthreadedsocketservice.c
+++ b/gio/gthreadedsocketservice.c
@@ -1,15 +1,27 @@
-/*
+/* GIO - GLib Input, Output and Streaming Library
+ *
  * Copyright © 2009 Codethink Limited
+ * Copyright © 2009 Red Hat, Inc
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; either version 2 of the licence or (at
  * your option) any later version.
  *
- * See the included COPYING file for more information.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
-
 /**
  * SECTION: gthreadedsocketservice
  * @title: GThreadedSocketService
@@ -24,10 +36,16 @@
  * The signal handler may perform blocking IO and need not return
  * until the connection is closed.
  *
+ * The service is implemented using a thread pool, so there is a
+ * limited amount of threads availible to serve incomming requests.
+ * The service automatically stops the #GSocketService from accepting
+ * new connections when all threads are busy.
+ *
  * As with #GSocketService, you may connect to ::run, or subclass and
  * override the default handler.
  */
 
+#include "config.h"
 #include "gthreadedsocketservice.h"
 
 #include "gnio-marshal.h"
diff --git a/gio/gthreadedsocketservice.h b/gio/gthreadedsocketservice.h
index ba80aa3..4ce7017 100644
--- a/gio/gthreadedsocketservice.h
+++ b/gio/gthreadedsocketservice.h
@@ -1,22 +1,33 @@
-/*
+/* GIO - GLib Input, Output and Streaming Library
+ *
  * Copyright © 2009 Codethink Limited
+ * Copyright © 2009 Red Hat, Inc
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; either version 2 of the licence or (at
  * your option) any later version.
  *
- * See the included COPYING file for more information.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
  *
  * Authors: Ryan Lortie <desrt desrt ca>
+ *          Alexander Larsson <alexl redhat com>
  */
 
 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
 #error "Only <gio/gio.h> can be included directly."
 #endif
 
-#ifndef _gthreadedsocketservice_h_
-#define _gthreadedsocketservice_h_
+#ifndef __G_THREADED_SOCKET_SERVICE_H__
+#define __G_THREADED_SOCKET_SERVICE_H__
 
 #include <gio/gsocketservice.h>
 
@@ -37,9 +48,17 @@ G_BEGIN_DECLS
                                                              G_TYPE_THREADED_SOCKET_SERVICE,                         \
                                                              GThreadedSocketServiceClass))
 
+/**
+ * GThreadedSocketService:
+ *
+ * A helper class for handling accepting incomming connections in the
+ * glib mainloop and handling them in a thread.
+ *
+ * Since: 2.22
+ **/
+typedef struct _GThreadedSocketService                      GThreadedSocketService;
 typedef struct _GThreadedSocketServicePrivate               GThreadedSocketServicePrivate;
 typedef struct _GThreadedSocketServiceClass                 GThreadedSocketServiceClass;
-typedef struct _GThreadedSocketService                      GThreadedSocketService;
 
 struct _GThreadedSocketServiceClass
 {
@@ -48,6 +67,13 @@ struct _GThreadedSocketServiceClass
   gboolean (* run) (GThreadedSocketService *service,
                     GSocketConnection      *connection,
                     GObject                *source_object);
+
+  /* Padding for future expansion */
+  void (*_g_reserved1) (void);
+  void (*_g_reserved2) (void);
+  void (*_g_reserved3) (void);
+  void (*_g_reserved4) (void);
+  void (*_g_reserved5) (void);
 };
 
 struct _GThreadedSocketService
@@ -61,4 +87,4 @@ GSocketService *        g_threaded_socket_service_new                   (void);
 
 G_END_DECLS
 
-#endif /* _gthreadedsocketservice_h_ */
+#endif /* __G_THREADED_SOCKET_SERVICE_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]