mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-22 18:20:09 +01:00
* glib/dbus-gthread.c: fix include * glib/dbus-glib.h: rename DBusMessageHandler for now. I think glib API needs to change, though, as you don't want to use DBusMessageFunction, you want to use the DBusMessageHandler object. Probably dbus_connection_open_with_g_main_loop() and dbus_connection_setup_g_main_loop() or something like that (but think of better names...) that just create a connection that has watch/timeout functions etc. already set up. * dbus/dbus-connection.c (dbus_connection_send_message_with_reply): new function just to show how the message handler helps us deal with replies. * dbus/dbus-list.c (_dbus_list_remove_last): new function * dbus/dbus-string.c (_dbus_string_test): free a string that wasn't * dbus/dbus-hash.c: use memory pools for the hash entries (rebuild_table): be more paranoid about overflow, and shrink table when we can (_dbus_hash_test): reduce number of sprintfs and write valid C89. Add tests for case where we grow and then shrink the hash table. * dbus/dbus-mempool.h, dbus/dbus-mempool.c: memory pools * dbus/dbus-connection.c (dbus_connection_register_handler) (dbus_connection_unregister_handler): new functions * dbus/dbus-message.c (dbus_message_get_name): new * dbus/dbus-list.c: fix docs typo * dbus/dbus-message-handler.h, dbus/dbus-message-handler.c: an object representing a handler for messages.
84 lines
2 KiB
C
84 lines
2 KiB
C
/* -*- mode: C; c-file-style: "gnu" -*- */
|
|
/* dbus-gthread.c GThread integration
|
|
*
|
|
* Copyright (C) 2002 CodeFactory AB
|
|
*
|
|
* Licensed under the Academic Free License version 1.2
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program 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 General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
|
|
#include <glib.h>
|
|
#include <dbus/dbus.h>
|
|
#include "dbus-glib.h"
|
|
|
|
static DBusMutex * dbus_gmutex_new (void);
|
|
static void dbus_gmutex_free (DBusMutex *mutex);
|
|
static dbus_bool_t dbus_gmutex_lock (DBusMutex *mutex);
|
|
static dbus_bool_t dbus_gmutex_unlock (DBusMutex *mutex);
|
|
|
|
static const DBusThreadFunctions functions =
|
|
{
|
|
DBUS_THREAD_FUNCTIONS_NEW_MASK |
|
|
DBUS_THREAD_FUNCTIONS_FREE_MASK |
|
|
DBUS_THREAD_FUNCTIONS_LOCK_MASK |
|
|
DBUS_THREAD_FUNCTIONS_UNLOCK_MASK,
|
|
dbus_gmutex_new,
|
|
dbus_gmutex_free,
|
|
dbus_gmutex_lock,
|
|
dbus_gmutex_unlock
|
|
};
|
|
|
|
static DBusMutex *
|
|
dbus_gmutex_new (void)
|
|
{
|
|
GMutex *mutex;
|
|
|
|
mutex = g_mutex_new ();
|
|
|
|
return (DBusMutex *)mutex;
|
|
}
|
|
|
|
static void
|
|
dbus_gmutex_free (DBusMutex *mutex)
|
|
{
|
|
g_mutex_free ((GMutex *)mutex);
|
|
}
|
|
|
|
static dbus_bool_t
|
|
dbus_gmutex_lock (DBusMutex *mutex)
|
|
{
|
|
g_mutex_lock ((GMutex *)mutex);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static dbus_bool_t
|
|
dbus_gmutex_unlock (DBusMutex *mutex)
|
|
{
|
|
g_mutex_unlock ((GMutex *)mutex);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
dbus_gthread_init (void)
|
|
{
|
|
if (!g_thread_supported ())
|
|
g_error ("g_thread_init() must be called before dbus_threads_init()");
|
|
|
|
dbus_threads_init (&functions);
|
|
}
|