X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-threads-internal.h;h=228a8c0589f7a1095b3d59d157b0129b7e234593;hb=0b2b6cba926a739ac56666f86ad4f88cbf5a8d48;hp=bcc4e6ba78f93a47bcd49deb243a662a1d5e8b07;hpb=d012387afef0ba02185ebe27bc6bb15551912e92;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h index bcc4e6b..228a8c0 100644 --- a/dbus/dbus-threads-internal.h +++ b/dbus/dbus-threads-internal.h @@ -17,7 +17,7 @@ * * 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 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef DBUS_THREADS_INTERNAL_H @@ -27,27 +27,75 @@ #include #include +/** + * @addtogroup DBusThreadsInternals + * @{ + */ + +/* glibc can implement global locks without needing an initialization step, + * which improves our thread-safety-by-default further. */ +#if defined(__GLIBC__) && defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +# define DBUS_HAVE_STATIC_RECURSIVE_MUTEXES 1 +#endif + +/** + * A mutex which is recursive if possible, else non-recursive. + * This is typically recursive, but that cannot be relied upon. + */ +typedef struct DBusRMutex DBusRMutex; + +/** + * A mutex suitable for use with condition variables. + * This is typically non-recursive. + */ +typedef struct DBusCMutex DBusCMutex; + +/** @} */ + DBUS_BEGIN_DECLS -DBusMutex* _dbus_mutex_new (void); -void _dbus_mutex_free (DBusMutex *mutex); -void _dbus_mutex_lock (DBusMutex *mutex); -void _dbus_mutex_unlock (DBusMutex *mutex); -void _dbus_mutex_new_at_location (DBusMutex **location_p); -void _dbus_mutex_free_at_location (DBusMutex **location_p); +void _dbus_rmutex_lock (DBusRMutex *mutex); +void _dbus_rmutex_unlock (DBusRMutex *mutex); +void _dbus_rmutex_new_at_location (DBusRMutex **location_p); +void _dbus_rmutex_free_at_location (DBusRMutex **location_p); + +void _dbus_cmutex_lock (DBusCMutex *mutex); +void _dbus_cmutex_unlock (DBusCMutex *mutex); +void _dbus_cmutex_new_at_location (DBusCMutex **location_p); +void _dbus_cmutex_free_at_location (DBusCMutex **location_p); DBusCondVar* _dbus_condvar_new (void); void _dbus_condvar_free (DBusCondVar *cond); void _dbus_condvar_wait (DBusCondVar *cond, - DBusMutex *mutex); + DBusCMutex *mutex); dbus_bool_t _dbus_condvar_wait_timeout (DBusCondVar *cond, - DBusMutex *mutex, + DBusCMutex *mutex, int timeout_milliseconds); void _dbus_condvar_wake_one (DBusCondVar *cond); -void _dbus_condvar_wake_all (DBusCondVar *cond); void _dbus_condvar_new_at_location (DBusCondVar **location_p); void _dbus_condvar_free_at_location (DBusCondVar **location_p); +/* Private to threading implementations and dbus-threads.c */ + +DBusRMutex *_dbus_platform_rmutex_new (void); +void _dbus_platform_rmutex_free (DBusRMutex *mutex); +void _dbus_platform_rmutex_lock (DBusRMutex *mutex); +void _dbus_platform_rmutex_unlock (DBusRMutex *mutex); + +DBusCMutex *_dbus_platform_cmutex_new (void); +void _dbus_platform_cmutex_free (DBusCMutex *mutex); +void _dbus_platform_cmutex_lock (DBusCMutex *mutex); +void _dbus_platform_cmutex_unlock (DBusCMutex *mutex); + +DBusCondVar* _dbus_platform_condvar_new (void); +void _dbus_platform_condvar_free (DBusCondVar *cond); +void _dbus_platform_condvar_wait (DBusCondVar *cond, + DBusCMutex *mutex); +dbus_bool_t _dbus_platform_condvar_wait_timeout (DBusCondVar *cond, + DBusCMutex *mutex, + int timeout_milliseconds); +void _dbus_platform_condvar_wake_one (DBusCondVar *cond); + DBUS_END_DECLS #endif /* DBUS_THREADS_INTERNAL_H */