dbus-threads.inc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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., 51 Franklin Street, Fifth Floor, Boston,
  21. * MA 02110-1301, USA.
  22. *
  23. }
  24. {#include <dbus/dbus-macros.h>
  25. #include <dbus/dbus-types.h>}
  26. type
  27. DBusMutex = record end;
  28. PDBusMutex = ^DBusMutex;
  29. DBusCondVar = record end;
  30. PDBusCondVar = ^DBusCondVar;
  31. DBusMutexNewFunction = function (): DBusMutex; cdecl;
  32. DBusMutexFreeFunction = procedure (mutex: PDBusMutex); cdecl;
  33. DBusMutexLockFunction = function (mutex: PDBusMutex): dbus_bool_t; cdecl;
  34. DBusMutexUnlockFunction = function (mutex: PDBusMutex): dbus_bool_t; cdecl;
  35. DBusRecursiveMutexNewFunction = function(): DBusMutex; cdecl;
  36. DBusRecursiveMutexFreeFunction = procedure (mutex: PDBusMutex); cdecl;
  37. DBusRecursiveMutexLockFunction = procedure (mutex: PDBusMutex); cdecl;
  38. DBusRecursiveMutexUnlockFunction = procedure (mutex: PDBusMutex); cdecl;
  39. DBusCondVarNewFunction = function (): PDBusCondVar; cdecl;
  40. DBusCondVarFreeFunction = procedure (cond: PDBusCondVar); cdecl;
  41. DBusCondVarWaitFunction = procedure (cond: PDBusCondVar; mutex: PDBusMutex); cdecl;
  42. DBusCondVarWaitTimeoutFunction = procedure (cond: PDBusCondVar; mutex: PDBusMutex;
  43. timeout_milliseconds: cint); cdecl;
  44. DBusCondVarWakeOneFunction = procedure (cond: PDBusCondVar); cdecl;
  45. DBusCondVarWakeAllFunction = procedure (cond: PDBusCondVar); cdecl;
  46. DBusThreadFunctionsMask =
  47. (
  48. DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK = 1 shl 0,
  49. DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK = 1 shl 1,
  50. DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK = 1 shl 2,
  51. DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK = 1 shl 3,
  52. DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK = 1 shl 4,
  53. DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK = 1 shl 5,
  54. DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK = 1 shl 6,
  55. DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK = 1 shl 7,
  56. DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK = 1 shl 8,
  57. DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK = 1 shl 9,
  58. DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK = 1 shl 10,
  59. DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK = 1 shl 11,
  60. DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK = 1 shl 12,
  61. DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK = 1 shl 13,
  62. DBUS_THREAD_FUNCTIONS_ALL_MASK = (1 shl 14) - 1
  63. );
  64. {
  65. * Functions that must be implemented to make the D-Bus
  66. * library thread-aware.
  67. }
  68. DBusThreadFunctions = record
  69. mask: cuint; {< Mask indicating which functions are present. }
  70. mutex_new: DBusMutexNewFunction; {< Function to create a mutex }
  71. mutex_free: DBusMutexFreeFunction; {< Function to free a mutex }
  72. mutex_lock: DBusMutexLockFunction; {< Function to lock a mutex }
  73. mutex_unlock: DBusMutexUnlockFunction; {< Function to unlock a mutex }
  74. condvar_new: DBusCondVarNewFunction; {< Function to create a condition variable }
  75. condvar_free: DBusCondVarFreeFunction; {< Function to free a condition variable }
  76. condvar_wait: DBusCondVarWaitFunction; {< Function to wait on a condition }
  77. condvar_wait_timeout: DBusCondVarWaitTimeoutFunction; {< Function to wait on a condition with a timeout }
  78. condvar_wake_one: DBusCondVarWakeOneFunction; {< Function to wake one thread waiting on the condition }
  79. condvar_wake_all: DBusCondVarWakeAllFunction; {< Function to wake all threads waiting on the condition }
  80. recursive_mutex_new: DBusRecursiveMutexNewFunction; {< Function to create a recursive mutex }
  81. recursive_mutex_free: DBusRecursiveMutexFreeFunction; {< Function to free a recursive mutex }
  82. recursive_mutex_lock: DBusRecursiveMutexLockFunction; {< Function to lock a recursive mutex }
  83. recursive_mutex_unlock: DBusRecursiveMutexUnlockFunction; {< Function to unlock a recursive mutex }
  84. padding1: procedure; {< Reserved for future expansion }
  85. padding2: procedure; {< Reserved for future expansion }
  86. padding3: procedure; {< Reserved for future expansion }
  87. padding4: procedure; {< Reserved for future expansion }
  88. end;
  89. PDBusThreadFunctions = ^DBusThreadFunctions;
  90. function dbus_threads_init(const functions: PDBusThreadFunctions): dbus_bool_t; cdecl; external LibDBus;
  91. function dbus_threads_init_default: dbus_bool_t; cdecl; external LibDBus;