gthread.inc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // included by glib2.pas
  2. {$IFDEF read_forward_definitions}
  3. {$ENDIF read_forward_definitions}
  4. //------------------------------------------------------------------------------
  5. {$IFDEF read_interface_types}
  6. PGThreadError = ^TGThreadError;
  7. TGThreadError = ( G_THREAD_ERROR_AGAIN { Resource temporarily unavailable });
  8. TGThreadFunc = function (data:gpointer):gpointer;cdecl;
  9. PGThreadPriority = ^TGThreadPriority;
  10. TGThreadPriority = (G_THREAD_PRIORITY_LOW,
  11. G_THREAD_PRIORITY_NORMAL,
  12. G_THREAD_PRIORITY_HIGH,
  13. G_THREAD_PRIORITY_URGENT);
  14. PGThread = ^TGThread;
  15. TGThread = record
  16. func : TGThreadFunc;
  17. data : gpointer;
  18. joinable : gboolean;
  19. priority : TGThreadPriority;
  20. end;
  21. PPGMutex = ^PGMutex;
  22. PGMutex = pointer; // GMutex;
  23. PGCond = pointer; // GCond;
  24. PGPrivate = pointer; // GPrivate;
  25. // typedef struct _GMutex* GStaticMutex;
  26. PGStaticMutex = ^TGStaticMutex;
  27. TGStaticMutex = PGMutex;
  28. PGThreadFunctions = ^TGThreadFunctions;
  29. TGThreadFunctions = record
  30. mutex_new : function :PGMutex; cdecl;
  31. mutex_lock : procedure (mutex:PGMutex); cdecl;
  32. mutex_trylock : function (mutex:PGMutex):gboolean; cdecl;
  33. mutex_unlock : procedure (mutex:PGMutex); cdecl;
  34. mutex_free : procedure (mutex:PGMutex); cdecl;
  35. cond_new : function :PGCond; cdecl;
  36. cond_signal : procedure (cond:PGCond); cdecl;
  37. cond_broadcast : procedure (cond:PGCond); cdecl;
  38. cond_wait : procedure (cond:PGCond; mutex:PGMutex); cdecl;
  39. cond_timed_wait : function (cond:PGCond; mutex:PGMutex; end_time:PGTimeVal):gboolean; cdecl;
  40. cond_free : procedure (cond:PGCond); cdecl;
  41. private_new : function (dest:TGDestroyNotify):PGPrivate; cdecl;
  42. private_get : function (private_key:PGPrivate):gpointer; cdecl;
  43. private_set : procedure (private_key:PGPrivate; data:gpointer); cdecl;
  44. thread_create : procedure (func:TGThreadFunc; data:gpointer; stack_size:gulong; joinable:gboolean; bound:gboolean;
  45. priority:TGThreadPriority; thread:gpointer; error:PPGError); cdecl;
  46. thread_yield : procedure ; cdecl;
  47. thread_join : procedure (thread:gpointer); cdecl;
  48. thread_exit : procedure ; cdecl;
  49. thread_set_priority : procedure (thread:gpointer; priority:TGThreadPriority); cdecl;
  50. thread_self : procedure (thread:gpointer); cdecl;
  51. thread_equal : function (thread1:gpointer; thread2:gpointer):gboolean; cdecl;
  52. end;
  53. PGStaticPrivate = ^TGStaticPrivate;
  54. TGStaticPrivate = record
  55. index : guint;
  56. end;
  57. PGStaticRecMutex = ^TGStaticRecMutex;
  58. TGStaticRecMutex = record
  59. mutex : TGStaticMutex;
  60. depth : guint;
  61. owner : TGSystemThread; // defined in glibconfig.inc
  62. end;
  63. PGStaticRWLock = ^TGStaticRWLock;
  64. TGStaticRWLock = record
  65. mutex : TGStaticMutex;
  66. read_cond : PGCond;
  67. write_cond : PGCond;
  68. read_counter : guint;
  69. write : gboolean;
  70. want_to_read : guint;
  71. want_to_write : guint;
  72. end;
  73. {$ENDIF read_interface_types}
  74. //------------------------------------------------------------------------------
  75. {$IFDEF read_interface_rest}
  76. function g_thread_error_quark : TGQuark; cdecl; external gthreadlib name 'g_thread_error_quark';
  77. function G_THREAD_ERROR: TGQuark;
  78. {$IFNDEF KYLIX}
  79. var
  80. {$IFDEF WINDOWS}
  81. g_thread_functions_for_glib_use : TGThreadFunctions; external gliblib name 'g_thread_functions_for_glib_use';
  82. g_thread_use_default_impl : gboolean; external gliblib name 'g_thread_use_default_impl';
  83. g_threads_got_initialized : gboolean; external gliblib name 'g_threads_got_initialized';
  84. {$ELSE}
  85. g_thread_functions_for_glib_use : TGThreadFunctions;cvar;external; // ?????
  86. g_thread_use_default_impl : gboolean;cvar;external;
  87. g_threads_got_initialized : gboolean;cvar;external;
  88. {$ENDIF}
  89. {$ENDIF}
  90. procedure g_thread_init(vtable:PGThreadFunctions);cdecl;external gthreadlib name 'g_thread_init';
  91. procedure g_thread_init_with_errorcheck_mutexes(vtable:PGThreadFunctions);cdecl;external gthreadlib name 'g_thread_init_with_errorcheck_mutexes';
  92. { A random number to recognize debug calls to g_mutex_... }
  93. const
  94. G_MUTEX_DEBUG_MAGIC = $f8e18ad7;
  95. function g_static_mutex_get_mutex_impl(mutex:PPGMutex):PGMutex;cdecl;external gthreadlib name 'g_static_mutex_get_mutex_impl';
  96. function g_thread_supported: gboolean;
  97. procedure g_mutex_lock (mutex: PGMutex);
  98. function g_mutex_trylock (mutex: PGMutex):gboolean;
  99. procedure g_mutex_unlock (mutex: PGMutex);
  100. procedure g_mutex_free (mutex: PGMutex);
  101. procedure g_cond_wait (cond: PGCond; mutex: PGMutex);
  102. function g_cond_timed_wait (cond: PGCond;
  103. mutex: PGMutex;
  104. end_time: PGTimeVal):gboolean;
  105. function g_mutex_new : PGMutex;
  106. function g_cond_new : PGCond;
  107. procedure g_cond_signal (cond: PGCond);
  108. procedure g_cond_broadcast (cond: PGCond);
  109. procedure g_cond_free (cond: PGCond);
  110. function g_private_new (dest: TGDestroyNotify): PGPrivate;
  111. function g_private_get (private_key: PGPrivate): gpointer;
  112. procedure g_private_set (var private_key: PGPrivate; data: gpointer);
  113. procedure g_thread_yield;
  114. function g_thread_create (func: TGThreadFunc;
  115. data: gpointer;
  116. joinable: gboolean;
  117. error: PPGError): PGThread;
  118. function g_thread_create_full (func : TGThreadFunc;
  119. data : gpointer;
  120. stack_size: gulong;
  121. joinable, bound: gboolean;
  122. priority : TGThreadPriority;
  123. error : ppGError): PGThread; cdecl; external gthreadlib name 'g_thread_create_full';
  124. function g_thread_self:PGThread;cdecl;external gthreadlib name 'g_thread_self';
  125. procedure g_thread_exit(retval:gpointer);cdecl;external gthreadlib name 'g_thread_exit';
  126. function g_thread_join(thread:PGThread):gpointer;cdecl;external gthreadlib name 'g_thread_join';
  127. procedure g_thread_set_priority(thread:PGThread; priority:TGThreadPriority);cdecl;external gthreadlib name 'g_thread_set_priority';
  128. procedure g_static_mutex_lock (mutex: PGStaticMutex);
  129. function g_static_mutex_trylock (mutex: PGStaticMutex): gboolean;
  130. procedure g_static_mutex_unlock (mutex: PGStaticMutex);
  131. procedure g_static_mutex_free(mutex:PGStaticMutex);cdecl;external gthreadlib name 'g_static_mutex_free';
  132. const
  133. nG_STATIC_PRIVATE_INIT = 0; //renamed because of conflict with function_name
  134. procedure g_static_private_init(private_key:PGStaticPrivate);cdecl;external gthreadlib name 'g_static_private_init';
  135. function g_static_private_get(private_key:PGStaticPrivate):gpointer;cdecl;external gthreadlib name 'g_static_private_get';
  136. procedure g_static_private_set(private_key:PGStaticPrivate; data:gpointer; notify:TGDestroyNotify);cdecl;external gthreadlib name 'g_static_private_set';
  137. procedure g_static_private_free(private_key:PGStaticPrivate);cdecl;external gthreadlib name 'g_static_private_free';
  138. const
  139. nG_STATIC_MUTEX_INIT = nil; // from glibconfig.h
  140. nG_STATIC_REC_MUTEX_INIT = nG_STATIC_MUTEX_INIT;
  141. procedure g_static_rec_mutex_init(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_init';
  142. procedure g_static_rec_mutex_lock(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_lock';
  143. function g_static_rec_mutex_trylock(mutex:PGStaticRecMutex):gboolean;cdecl;external gthreadlib name 'g_static_rec_mutex_trylock';
  144. procedure g_static_rec_mutex_unlock(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_unlock';
  145. procedure g_static_rec_mutex_lock_full(mutex:PGStaticRecMutex; depth:guint);cdecl;external gthreadlib name 'g_static_rec_mutex_lock_full';
  146. function g_static_rec_mutex_unlock_full(mutex:PGStaticRecMutex):guint;cdecl;external gthreadlib name 'g_static_rec_mutex_unlock_full';
  147. procedure g_static_rec_mutex_free(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_free';
  148. procedure g_static_rw_lock_init(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_init';
  149. procedure g_static_rw_lock_reader_lock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_reader_lock';
  150. function g_static_rw_lock_reader_trylock(lock:PGStaticRWLock):gboolean;cdecl;external gthreadlib name 'g_static_rw_lock_reader_trylock';
  151. procedure g_static_rw_lock_reader_unlock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_reader_unlock';
  152. procedure g_static_rw_lock_writer_lock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_writer_lock';
  153. function g_static_rw_lock_writer_trylock(lock:PGStaticRWLock):gboolean;cdecl;external gthreadlib name 'g_static_rw_lock_writer_trylock';
  154. procedure g_static_rw_lock_writer_unlock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_writer_unlock';
  155. procedure g_static_rw_lock_free(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_free';
  156. {$ENDIF read_interface_rest}
  157. // included by glib2.pas