dbus-threads.inc 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. { -*- mode: C; c-file-style: "gnu" -*- }
  2. { dbus-threads.h D-Bus threads handling
  3. *
  4. * Copyright (C) 2002 Red Hat Inc.
  5. *
  6. * Licensed under the Academic Free License version 2.1
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. }
  23. {#include <dbus/dbus-macros.h>
  24. #include <dbus/dbus-types.h>}
  25. type
  26. DBusMutex = record end;
  27. PDBusMutex = ^DBusMutex;
  28. DBusCondVar = record end;
  29. PDBusCondVar = ^DBusCondVar;
  30. DBusMutexNewFunction = function (): DBusMutex;
  31. DBusMutexFreeFunction = procedure (mutex: PDBusMutex);
  32. DBusMutexLockFunction = function (mutex: PDBusMutex): dbus_bool_t;
  33. DBusMutexUnlockFunction = function (mutex: PDBusMutex): dbus_bool_t;
  34. DBusCondVarNewFunction = function (): PDBusCondVar;
  35. DBusCondVarFreeFunction = procedure (cond: PDBusCondVar);
  36. DBusCondVarWaitFunction = procedure (cond: PDBusCondVar; mutex: PDBusMutex);
  37. DBusCondVarWaitTimeoutFunction = procedure (cond: PDBusCondVar; mutex: PDBusMutex;
  38. timeout_milliseconds: cint);
  39. DBusCondVarWakeOneFunction = procedure (cond: PDBusCondVar);
  40. DBusCondVarWakeAllFunction = procedure (cond: PDBusCondVar);
  41. DBusThreadFunctionsMask =
  42. (
  43. DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK = 1 shl 0,
  44. DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK = 1 shl 1,
  45. DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK = 1 shl 2,
  46. DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK = 1 shl 3,
  47. DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK = 1 shl 4,
  48. DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK = 1 shl 5,
  49. DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK = 1 shl 6,
  50. DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK = 1 shl 7,
  51. DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 shl 8,
  52. DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 shl 9,
  53. DBUS_THREAD_FUNCTIONS_ALL_MASK = (1 shl 10) - 1
  54. );
  55. {
  56. * Functions that must be implemented to make the D-Bus
  57. * library thread-aware.
  58. }
  59. DBusThreadFunctions = record
  60. mask: cuint; {< Mask indicating which functions are present. }
  61. mutex_new: DBusMutexNewFunction; {< Function to create a mutex }
  62. mutex_free: DBusMutexFreeFunction; {< Function to free a mutex }
  63. mutex_lock: DBusMutexLockFunction; {< Function to lock a mutex }
  64. mutex_unlock: DBusMutexUnlockFunction; {< Function to unlock a mutex }
  65. condvar_new: DBusCondVarNewFunction; {< Function to create a condition variable }
  66. condvar_free: DBusCondVarFreeFunction; {< Function to free a condition variable }
  67. condvar_wait: DBusCondVarWaitFunction; {< Function to wait on a condition }
  68. condvar_wait_timeout: DBusCondVarWaitTimeoutFunction; {< Function to wait on a condition with a timeout }
  69. condvar_wake_one: DBusCondVarWakeOneFunction; {< Function to wake one thread waiting on the condition }
  70. condvar_wake_all: DBusCondVarWakeAllFunction; {< Function to wake all threads waiting on the condition }
  71. padding1: procedure; {< Reserved for future expansion }
  72. padding2: procedure; {< Reserved for future expansion }
  73. padding3: procedure; {< Reserved for future expansion }
  74. padding4: procedure; {< Reserved for future expansion }
  75. padding5: procedure; {< Reserved for future expansion }
  76. padding6: procedure; {< Reserved for future expansion }
  77. padding7: procedure; {< Reserved for future expansion }
  78. padding8: procedure; {< Reserved for future expansion }
  79. end;
  80. PDBusThreadFunctions = ^DBusThreadFunctions;
  81. function dbus_threads_init(const functions: PDBusThreadFunctions): dbus_bool_t; cdecl; external LibDBus;