mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-02 11:56:38 +02:00
Actually implement max_threads for GThreadedSocketService
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gsocketconnection.h"
|
#include "gsocketconnection.h"
|
||||||
#include "gthreadedsocketservice.h"
|
#include "gthreadedsocketservice.h"
|
||||||
|
#include "glibintl.h"
|
||||||
|
|
||||||
#include "gio-marshal.h"
|
#include "gio-marshal.h"
|
||||||
|
|
||||||
@@ -59,6 +60,13 @@ G_DEFINE_TYPE (GThreadedSocketService,
|
|||||||
g_threaded_socket_service,
|
g_threaded_socket_service,
|
||||||
G_TYPE_SOCKET_SERVICE);
|
G_TYPE_SOCKET_SERVICE);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_MAX_THREADS
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
G_LOCK_DEFINE_STATIC(job_count);
|
G_LOCK_DEFINE_STATIC(job_count);
|
||||||
|
|
||||||
struct _GThreadedSocketServicePrivate
|
struct _GThreadedSocketServicePrivate
|
||||||
@@ -162,6 +170,44 @@ g_threaded_socket_service_finalize (GObject *object)
|
|||||||
->finalize (object);
|
->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_threaded_socket_service_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GThreadedSocketService *service = G_THREADED_SOCKET_SERVICE (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_MAX_THREADS:
|
||||||
|
g_value_set_int (value, service->priv->max_threads);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_threaded_socket_service_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GThreadedSocketService *service = G_THREADED_SOCKET_SERVICE (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_MAX_THREADS:
|
||||||
|
service->priv->max_threads = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
|
g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
|
||||||
@@ -173,6 +219,8 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
|
|||||||
|
|
||||||
gobject_class->constructed = g_threaded_socket_service_constructed;
|
gobject_class->constructed = g_threaded_socket_service_constructed;
|
||||||
gobject_class->finalize = g_threaded_socket_service_finalize;
|
gobject_class->finalize = g_threaded_socket_service_finalize;
|
||||||
|
gobject_class->set_property = g_threaded_socket_service_set_property;
|
||||||
|
gobject_class->get_property = g_threaded_socket_service_get_property;
|
||||||
|
|
||||||
ss_class->incoming = g_threaded_socket_service_incoming;
|
ss_class->incoming = g_threaded_socket_service_incoming;
|
||||||
|
|
||||||
@@ -196,6 +244,15 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
|
|||||||
g_signal_accumulator_true_handled, NULL,
|
g_signal_accumulator_true_handled, NULL,
|
||||||
_gio_marshal_BOOLEAN__OBJECT_OBJECT, G_TYPE_BOOLEAN,
|
_gio_marshal_BOOLEAN__OBJECT_OBJECT, G_TYPE_BOOLEAN,
|
||||||
2, G_TYPE_SOCKET_CONNECTION, G_TYPE_OBJECT);
|
2, G_TYPE_SOCKET_CONNECTION, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_MAX_THREADS,
|
||||||
|
g_param_spec_int ("max-threads",
|
||||||
|
P_("Max threads"),
|
||||||
|
P_("The max number of threads handling clients for this service"),
|
||||||
|
-1,
|
||||||
|
G_MAXINT,
|
||||||
|
10,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +267,9 @@ g_threaded_socket_service_class_init (GThreadedSocketServiceClass *class)
|
|||||||
GSocketService *
|
GSocketService *
|
||||||
g_threaded_socket_service_new (int max_threads)
|
g_threaded_socket_service_new (int max_threads)
|
||||||
{
|
{
|
||||||
return g_object_new (G_TYPE_THREADED_SOCKET_SERVICE, NULL);
|
return g_object_new (G_TYPE_THREADED_SOCKET_SERVICE,
|
||||||
|
"max-threads", max_threads,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __G_THREADED_SOCKET_SERVICE_C__
|
#define __G_THREADED_SOCKET_SERVICE_C__
|
||||||
|
Reference in New Issue
Block a user