projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
semver: 1.0 -> 1
[awesomized/libmemcached]
/
test
/
tests
/
memcached
/
util_pool_thread.cpp
diff --git
a/test/tests/memcached/util_pool_thread.cpp
b/test/tests/memcached/util_pool_thread.cpp
index 0f90a008f17cce081aea94ec1c6bf47f77697f60..b177b2a3e013e23b96362bfc0c72f783ade183cf 100644
(file)
--- a/
test/tests/memcached/util_pool_thread.cpp
+++ b/
test/tests/memcached/util_pool_thread.cpp
@@
-1,36
+1,18
@@
#include "test/lib/common.hpp"
#include "test/lib/common.hpp"
-#if HAVE_SEMAPHORE_H
-
-#include "libmemcachedutil-1.0/pool.h"
+#include "libmemcachedutil-1/pool.h"
#include <cassert>
#include <cassert>
-#include "semaphore.h"
struct test_pool_context_st {
volatile memcached_return_t rc;
memcached_pool_st *pool;
memcached_st *memc;
struct test_pool_context_st {
volatile memcached_return_t rc;
memcached_pool_st *pool;
memcached_st *memc;
- sem_t _lock;
-
- test_pool_context_st(memcached_pool_st *pool_arg, memcached_st *memc_arg) :
- rc(MEMCACHED_FAILURE),
- pool(pool_arg),
- memc(memc_arg) {
- if (sem_init(&_lock, 0, 0)) {
- perror("sem_init()");
- }
- }
-
- void wait() {
- sem_wait(&_lock);
- }
-
- void release() {
- sem_post(&_lock);
- }
- ~test_pool_context_st() {
- sem_destroy(&_lock);
+ test_pool_context_st(memcached_pool_st *pool_arg, memcached_st *memc_arg)
+ : rc(MEMCACHED_FAILURE)
+ , pool(pool_arg)
+ , memc(memc_arg)
+ {
}
};
}
};
@@
-40,7
+22,6
@@
static void *connection_release(void *arg) {
this_thread::sleep_for(200ms);
auto res = static_cast<test_pool_context_st *>(arg);
res->rc = memcached_pool_release(res->pool, res->memc);
this_thread::sleep_for(200ms);
auto res = static_cast<test_pool_context_st *>(arg);
res->rc = memcached_pool_release(res->pool, res->memc);
- res->release();
pthread_exit(arg);
}
pthread_exit(arg);
}
@@
-67,7
+48,6
@@
TEST_CASE("memcached_util_pool_thread") {
test_pool_context_st item(pool, pool_memc);
REQUIRE(0 == pthread_create(&tid, nullptr, connection_release, &item));
test_pool_context_st item(pool, pool_memc);
REQUIRE(0 == pthread_create(&tid, nullptr, connection_release, &item));
- item.wait();
memcached_st *pop_memc;
do {
memcached_st *pop_memc;
do {
@@
-92,5
+72,3
@@
TEST_CASE("memcached_util_pool_thread") {
REQUIRE(memcached_pool_destroy(pool) == *memc);
}
REQUIRE(memcached_pool_destroy(pool) == *memc);
}
-
-#endif // HAVE_SEMAPHORE_H