X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgthreadedsocketservice.c;h=ab4bd0050b220aa87ff220202f281a5ac3a45d6e;hb=7fd6f07d498063470903a886b4805a13bd333908;hp=6908d2a0e523302ee31cef3b860d4e147ced88f5;hpb=01f63b19f9f0ddfff3ccfbb1a15ba6e3d68d9c67;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gthreadedsocketservice.c b/gio/gthreadedsocketservice.c
index 6908d2a..ab4bd00 100644
--- a/gio/gthreadedsocketservice.c
+++ b/gio/gthreadedsocketservice.c
@@ -14,9 +14,7 @@
* 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.
+ * Public License along with this library; if not, see .
*
* Authors: Ryan Lortie
* Alexander Larsson
@@ -26,6 +24,7 @@
* SECTION:gthreadedsocketservice
* @title: GThreadedSocketService
* @short_description: A threaded GSocketService
+ * @include: gio/gio.h
* @see_also: #GSocketService.
*
* A #GThreadedSocketService is a simple subclass of #GSocketService
@@ -50,14 +49,18 @@
#include "gthreadedsocketservice.h"
#include "glibintl.h"
-#include "gio-marshal.h"
-
+struct _GThreadedSocketServicePrivate
+{
+ GThreadPool *thread_pool;
+ int max_threads;
+ gint job_count;
+};
static guint g_threaded_socket_service_run_signal;
-G_DEFINE_TYPE (GThreadedSocketService,
- g_threaded_socket_service,
- G_TYPE_SOCKET_SERVICE);
+G_DEFINE_TYPE_WITH_PRIVATE (GThreadedSocketService,
+ g_threaded_socket_service,
+ G_TYPE_SOCKET_SERVICE)
enum
{
@@ -65,19 +68,10 @@ enum
PROP_MAX_THREADS
};
-
G_LOCK_DEFINE_STATIC(job_count);
-struct _GThreadedSocketServicePrivate
-{
- GThreadPool *thread_pool;
- int max_threads;
- gint job_count;
-};
-
typedef struct
{
- GThreadedSocketService *service;
GSocketConnection *connection;
GObject *source_object;
} GThreadedSocketServiceData;
@@ -90,10 +84,9 @@ g_threaded_socket_service_func (gpointer _data,
GThreadedSocketServiceData *data = _data;
gboolean result;
- g_signal_emit (data->service, g_threaded_socket_service_run_signal,
+ g_signal_emit (threaded, g_threaded_socket_service_run_signal,
0, data->connection, data->source_object, &result);
- g_object_unref (data->service);
g_object_unref (data->connection);
if (data->source_object)
g_object_unref (data->source_object);
@@ -103,6 +96,8 @@ g_threaded_socket_service_func (gpointer _data,
if (threaded->priv->job_count-- == threaded->priv->max_threads)
g_socket_service_start (G_SOCKET_SERVICE (threaded));
G_UNLOCK (job_count);
+
+ g_object_unref (threaded);
}
static gboolean
@@ -116,7 +111,10 @@ g_threaded_socket_service_incoming (GSocketService *service,
threaded = G_THREADED_SOCKET_SERVICE (service);
data = g_slice_new (GThreadedSocketServiceData);
- data->service = g_object_ref (service);
+
+ /* Ref the socket service for the thread */
+ g_object_ref (service);
+
data->connection = g_object_ref (connection);
if (source_object)
data->source_object = g_object_ref (source_object);
@@ -138,9 +136,7 @@ g_threaded_socket_service_incoming (GSocketService *service,
static void
g_threaded_socket_service_init (GThreadedSocketService *service)
{
- service->priv = G_TYPE_INSTANCE_GET_PRIVATE (service,
- G_TYPE_THREADED_SOCKET_SERVICE,
- GThreadedSocketServicePrivate);
+ service->priv = g_threaded_socket_service_get_instance_private (service);
service->priv->max_threads = 10;
}
@@ -163,7 +159,7 @@ g_threaded_socket_service_finalize (GObject *object)
{
GThreadedSocketService *service = G_THREADED_SOCKET_SERVICE (object);
- g_thread_pool_free (service->priv->thread_pool, FALSE, TRUE);
+ g_thread_pool_free (service->priv->thread_pool, FALSE, FALSE);
G_OBJECT_CLASS (g_threaded_socket_service_parent_class)
->finalize (object);
@@ -214,8 +210,6 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GSocketServiceClass *ss_class = &class->parent_class;
- g_type_class_add_private (class, sizeof (GThreadedSocketServicePrivate));
-
gobject_class->constructed = g_threaded_socket_service_constructed;
gobject_class->finalize = g_threaded_socket_service_finalize;
gobject_class->set_property = g_threaded_socket_service_set_property;
@@ -240,7 +234,7 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
g_signal_new ("run", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GThreadedSocketServiceClass, run),
g_signal_accumulator_true_handled, NULL,
- _gio_marshal_BOOLEAN__OBJECT_OBJECT, G_TYPE_BOOLEAN,
+ NULL, G_TYPE_BOOLEAN,
2, G_TYPE_SOCKET_CONNECTION, G_TYPE_OBJECT);
g_object_class_install_property (gobject_class, PROP_MAX_THREADS,
@@ -259,7 +253,7 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
* handling incoming clients, -1 means no limit
*
* Creates a new #GThreadedSocketService with no listeners. Listeners
- * must be added with g_socket_service_add_listeners().
+ * must be added with one of the #GSocketListener "add" methods.
*
* Returns: a new #GSocketService.
*