#ifndef _DWC_MUTEX_H
#define _DWC_MUTEX_H

/*--------------------------------------------------------------------------
 *  Copyright (c) 2001-2004 Igor Daniloff. 
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at this directory.
 *------------------------------------------------------------------------*/
 
/* $Id: dwc_mutex.h,v 1.16 2005/09/21 09:20:44 asv Exp $ */

#include "dwc_type.h"


#if defined(__THREAD_BASED_DW)

#ifdef __UNIX_DW
#include <pthread.h>
#endif /* __UNIX_DW */
#ifdef __WIN32_DW
#include <windows.h>
#endif /* __WIN32_DW */


#define INVALID_MUTEX             NULL
typedef struct DWC_int_mutex_t*   DWC_mutex_t;        
#if defined(__UNIX_DW)
typedef pthread_mutex_t           dwc_sysmutex_t;
#endif /* UNIX */
#if defined(__WIN32_DW)
typedef HANDLE                    dwc_sysmutex_t;
#endif /* WIN32 */

#else /* !__THREAD_BASED_DW */

#define INVALID_MUTEX             0
typedef int                       DWC_mutex_t;
typedef int                       dwc_sysmutex_t;

#endif /* __THREAD_BASED_DW */

#ifdef __cplusplus
extern "C" {
#endif

typedef DWC_mutex_t               dwc_mutex_t;

DWC_mutex_t         dwc_mutex_create( DWC_const_string_t );
dwc_sysmutex_t*     dwc_mutex_handle( DWC_mutex_t );
DWC_bool_t          dwc_mutex_lock( DWC_mutex_t );
DWC_bool_t          dwc_mutex_unlock( DWC_mutex_t );
DWC_error_code_t    dwc_mutex_destroy( DWC_mutex_t );

#ifdef __cplusplus
}
#endif

#endif /* _DWC_MUTEX_H */
