added qse_rwl_t
This commit is contained in:
@ -119,7 +119,9 @@ struct qse_btime_t
|
||||
/*int offset;*/
|
||||
};
|
||||
|
||||
#define qse_cleartime(x) ((x)->sec = (x)->nsec = 0);
|
||||
#define qse_inittime(x,s,ns) (((x)->sec = (s)), ((x)->nsec = (ns)))
|
||||
#define qse_cleartime(x) qse_inittime(x,0,0)
|
||||
/*#define qse_cleartime(x) ((x)->sec = (x)->nsec = 0)*/
|
||||
#define qse_cmptime(x,y) \
|
||||
(((x)->sec == (y)->sec)? ((x)->nsec - (y)->nsec): \
|
||||
((x)->sec - (y)->sec))
|
||||
@ -142,7 +144,6 @@ QSE_EXPORT int qse_settime (
|
||||
const qse_ntime_t* nt
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_gmtime() function converts numeric time to broken-down time.
|
||||
*/
|
||||
@ -188,7 +189,7 @@ QSE_EXPORT void qse_addtime (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_subtime() function subtract y from x and stores the result in z.
|
||||
* The qse_subtime() function subtract y from x and stores the result in z.
|
||||
*/
|
||||
QSE_EXPORT void qse_subtime (
|
||||
const qse_ntime_t* x,
|
||||
|
@ -3,6 +3,7 @@ pkgincludedir = $(includedir)/qse/sys
|
||||
pkginclude_HEADERS = \
|
||||
cnd.h \
|
||||
mtx.h \
|
||||
rwl.h \
|
||||
thr.h
|
||||
|
||||
if ENABLE_CXX
|
||||
|
@ -117,7 +117,8 @@ am__can_run_installinfo = \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__pkginclude_HEADERS_DIST = cnd.h mtx.h thr.h SocketAddress.hpp
|
||||
am__pkginclude_HEADERS_DIST = cnd.h mtx.h rwl.h thr.h \
|
||||
SocketAddress.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
@ -343,7 +344,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = cnd.h mtx.h thr.h $(am__append_1)
|
||||
pkginclude_HEADERS = cnd.h mtx.h rwl.h thr.h $(am__append_1)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -37,8 +37,11 @@ typedef struct qse_cnd_t qse_cnd_t;
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* define nothing */
|
||||
|
||||
#elif defined(__OS2__)
|
||||
# error not implemented
|
||||
/* typdef unsigned long ULONG;
|
||||
* typedef ULONG HEV; */
|
||||
typedef unsigned long qse_cnd_hnd_t;
|
||||
|
||||
#elif defined(__DOS__)
|
||||
# error not implemented
|
||||
@ -83,6 +86,11 @@ struct qse_cnd_t
|
||||
unsigned int gone;
|
||||
unsigned long blocked;
|
||||
unsigned int waiting;
|
||||
#elif defined(__OS2__)
|
||||
qse_size_t wait_count;
|
||||
qse_cnd_hnd_t hnd;
|
||||
|
||||
|
||||
#else
|
||||
qse_cnd_hnd_t hnd;
|
||||
#endif
|
||||
@ -94,8 +102,8 @@ extern "C" {
|
||||
|
||||
|
||||
qse_cnd_t* qse_cnd_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
void qse_cnd_close (
|
||||
@ -103,8 +111,8 @@ void qse_cnd_close (
|
||||
);
|
||||
|
||||
int qse_cnd_init (
|
||||
qse_cnd_t* cnd,
|
||||
qse_mmgr_t* mmgr
|
||||
qse_cnd_t* cnd,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_cnd_fini (
|
||||
|
112
qse/include/qse/sys/rwl.h
Normal file
112
qse/include/qse/sys/rwl.h
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_SYS_RWL_H_
|
||||
#define _QSE_SYS_RWL_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/sys/mtx.h>
|
||||
#include <qse/sys/cnd.h>
|
||||
|
||||
enum qse_rwl_flag_t
|
||||
{
|
||||
QSE_RWL_PREFER_WRITER = (1 << 0)
|
||||
};
|
||||
typedef enum qse_rwl_flag_t qse_rwl_flag_t;
|
||||
|
||||
struct qse_rwl_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
int flags;
|
||||
|
||||
qse_mtx_t mtx;
|
||||
qse_cnd_t rcnd;
|
||||
qse_cnd_t wcnd;
|
||||
|
||||
qse_size_t rwait_count;
|
||||
qse_size_t wwait_count;
|
||||
qse_size_t ractive_count;
|
||||
qse_size_t wactive_count;
|
||||
};
|
||||
|
||||
typedef struct qse_rwl_t qse_rwl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_rwl_t* qse_rwl_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_rwl_close (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_init (
|
||||
qse_rwl_t* rwl,
|
||||
qse_mmgr_t* mmgr,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_rwl_fini (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_rwl_getmmgr (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
void* qse_rwl_getxtn (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_lockr (
|
||||
qse_rwl_t* rwl,
|
||||
qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
int qse_rwl_unlockr (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_lockw (
|
||||
qse_rwl_t* rwl,
|
||||
qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
int qse_rwl_unlockw (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user