Add macros
CONCURRENT_DEF_AS CONCURRENT_RP_DEF_AS
This commit is contained in:
1 parent
2cfac5c332
commit
c180981768
2 files changed
+39
No files matched your search
@@ -40,6 +40,17 @@
|
|||||||
M_END_PROTECTED_CODE
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
|
|
||||||
|
/* Define a protected concurrent container and its associated functions
|
||||||
|
based on the given container as the given name name_t
|
||||||
|
USAGE: CONCURRENT_DEF_AS(name, name_t, type [, oplist_of_the_type]) */
|
||||||
|
#define CONCURRENT_DEF_AS(name, name_t, ...) \
|
||||||
|
M_BEGIN_PROTECTED_CODE \
|
||||||
|
CONCURRENTI_DEF_P1(M_IF_NARGS_EQ1(__VA_ARGS__) \
|
||||||
|
((name, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__)(), name_t ), \
|
||||||
|
(name, __VA_ARGS__, name_t ))) \
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
|
|
||||||
/* Define the oplist of a protected concurrent container given its name and its oplist.
|
/* Define the oplist of a protected concurrent container given its name and its oplist.
|
||||||
USAGE: CONCURRENT_OPLIST(name[, oplist of the type]) */
|
USAGE: CONCURRENT_OPLIST(name[, oplist of the type]) */
|
||||||
#define CONCURRENT_OPLIST(...) \
|
#define CONCURRENT_OPLIST(...) \
|
||||||
@@ -60,6 +71,19 @@
|
|||||||
M_END_PROTECTED_CODE
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
|
|
||||||
|
/* Define a protected concurrent container and its associated functions
|
||||||
|
as the given name name_t
|
||||||
|
based on its given container. Operations that perform only read of the container
|
||||||
|
can be done in parallel.
|
||||||
|
USAGE: CONCURRENT_RP_DEF_AS(name, name_t, type [, oplist_of_the_type]) */
|
||||||
|
#define CONCURRENT_RP_DEF_AS(name, name_t, ...) \
|
||||||
|
M_BEGIN_PROTECTED_CODE \
|
||||||
|
CONCURRENTI_RP_DEF_P1(M_IF_NARGS_EQ1(__VA_ARGS__) \
|
||||||
|
((name, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__)(), name_t ), \
|
||||||
|
(name, __VA_ARGS__, name_t ))) \
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
|
|
||||||
/********************************** INTERNAL ************************************/
|
/********************************** INTERNAL ************************************/
|
||||||
|
|
||||||
/* Deferred evaluation for the oplist definition,
|
/* Deferred evaluation for the oplist definition,
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ CONCURRENT_RP_DEF(rparray1, array1_t, ARRAY_OPLIST(array1))
|
|||||||
|
|
||||||
CONCURRENT_RP_DEF(rpdict1, dict1_t, DICT_OPLIST(dict1))
|
CONCURRENT_RP_DEF(rpdict1, dict1_t, DICT_OPLIST(dict1))
|
||||||
|
|
||||||
|
CONCURRENT_DEF_AS(ConcurrentDouble, ConcurrentDouble, double)
|
||||||
|
CONCURRENT_RP_DEF_AS(ConcurrentRpDouble, ConcurrentRpDouble, double)
|
||||||
|
|
||||||
/* OA dict needs more operators than the default ones to work */
|
/* OA dict needs more operators than the default ones to work */
|
||||||
static inline bool int_oor_equal_p(int s, unsigned char n)
|
static inline bool int_oor_equal_p(int s, unsigned char n)
|
||||||
{
|
{
|
||||||
@@ -210,11 +213,23 @@ static void test_rp_basic(void)
|
|||||||
rpdict1_clear(dict);
|
rpdict1_clear(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_double(void)
|
||||||
|
{
|
||||||
|
ConcurrentDouble d;
|
||||||
|
ConcurrentDouble_init(d);
|
||||||
|
ConcurrentDouble_clear(d);
|
||||||
|
|
||||||
|
ConcurrentRpDouble r;
|
||||||
|
ConcurrentRpDouble_init(r);
|
||||||
|
ConcurrentRpDouble_clear(r);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
test_basic();
|
test_basic();
|
||||||
test_rp_basic();
|
test_rp_basic();
|
||||||
test_thread();
|
test_thread();
|
||||||
test_rp_thread();
|
test_rp_thread();
|
||||||
|
test_double();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user