From c73804dc7ab6541a5d41f8226697619386f7569a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 15 Jun 2009 18:45:17 +0000 Subject: [PATCH] 2009-06-15 20:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * include/hbextern.ch * source/vm/thread.c + Added HB_MUTEXWAITERSCOUNT() to core. (slightly rewritten using local functions) - examples/uhttpd2/umutex.c - No longer needed. --- harbour/ChangeLog | 9 ++++++++ harbour/examples/uhttpd2/umutex.c | 34 ------------------------------- harbour/include/hbextern.ch | 1 + harbour/source/vm/thread.c | 13 ++++++++++++ 4 files changed, 23 insertions(+), 34 deletions(-) delete mode 100644 harbour/examples/uhttpd2/umutex.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 561ee3433a..b5e715de49 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,15 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-15 20:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * include/hbextern.ch + * source/vm/thread.c + + Added HB_MUTEXWAITERSCOUNT() to core. + (slightly rewritten using local functions) + + - examples/uhttpd2/umutex.c + - No longer needed. + 2009-06-15 20:37 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * examples/uhttpd2/uwidgets.prg * examples/uhttpd2/uhbext.prg diff --git a/harbour/examples/uhttpd2/umutex.c b/harbour/examples/uhttpd2/umutex.c deleted file mode 100644 index e42be082f6..0000000000 --- a/harbour/examples/uhttpd2/umutex.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * $Id$ - */ - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbthread.h" - -typedef struct _HB_MUTEX -{ - int lock_count; - int lockers; - int waiters; - PHB_ITEM events; - HB_THREAD_ID owner; - HB_RAWCRITICAL_T mutex; - HB_RAWCOND_T cond_l; - HB_RAWCOND_T cond_w; - BOOL fSync; - struct _HB_MUTEX * pNext; - struct _HB_MUTEX * pPrev; -} -HB_MUTEX, * PHB_MUTEX; - - -HB_FUNC( HB_MUTEXWAITERSCOUNT ) -{ - PHB_MUTEX pItem = ( PHB_MUTEX ) hb_param( 1, HB_IT_POINTER ); - - if( pItem ) - hb_retni( ( ( PHB_MUTEX ) hb_itemGetPtr( pItem ) )->waiters ); - else - hb_ret(); -} diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index f84162622e..c763aa2216 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -1015,6 +1015,7 @@ EXTERNAL HB_MUTEXNOTIFY EXTERNAL HB_MUTEXNOTIFYALL EXTERNAL HB_MUTEXSUBSCRIBE EXTERNAL HB_MUTEXSUBSCRIBENOW +EXTERNAL HB_MUTEXWAITERSCOUNT /* Codepage support */ EXTERNAL HB_CODEPAGE_BG866 diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index 1207fcb112..39c1fe6242 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -2318,6 +2318,19 @@ HB_FUNC( HB_MUTEXSUBSCRIBENOW ) } } +HB_FUNC( HB_MUTEXWAITERSCOUNT ) +{ + PHB_ITEM pItem = hb_mutexParam( 1 ); + + if( pItem ) + { + PHB_MUTEX pMutex = hb_mutexPtr( pItem ); + + if( pMutex ) + hb_retni( pMutex->waiters ); + } +} + HB_FUNC( HB_MTVM ) { HB_STACK_TLS_PRELOAD