mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
waiter_impl -> waiter_wrapper
This commit is contained in:
parent
e8dda2c1d4
commit
a4b93f60cf
@ -4,8 +4,6 @@ TARGET = ipc
|
||||
CONFIG -= qt
|
||||
CONFIG += c++14 c++1z # may be useless
|
||||
|
||||
!msvc:QMAKE_CXXFLAGS += -Wno-attributes -Wno-missing-field-initializers
|
||||
|
||||
DEFINES += __IPC_LIBRARY__
|
||||
DESTDIR = ../output
|
||||
|
||||
@ -29,7 +27,7 @@ HEADERS += \
|
||||
../src/memory/wrapper.h \
|
||||
../src/memory/resource.h \
|
||||
../src/platform/detail.h \
|
||||
../src/platform/waiter.h \
|
||||
../src/platform/waiter_wrapper.h \
|
||||
../src/circ/elem_def.h \
|
||||
../src/circ/elem_array.h \
|
||||
../src/prod_cons.h \
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include "rw_lock.h"
|
||||
|
||||
#include "platform/waiter.h"
|
||||
#include "platform/waiter_wrapper.h"
|
||||
#include "platform/detail.h"
|
||||
|
||||
namespace ipc {
|
||||
|
||||
@ -68,8 +68,8 @@ public:
|
||||
|
||||
void close(handle_t h) {
|
||||
if (h == invalid()) return;
|
||||
::printf("closing...\n");
|
||||
if (counter_.fetch_sub(1, std::memory_order_acq_rel) == 1) {
|
||||
::printf("destroy...\n");
|
||||
::pthread_cond_destroy(&cond_);
|
||||
::pthread_mutex_destroy(&mutex_);
|
||||
::printf("destroy end...\n");
|
||||
@ -78,6 +78,7 @@ public:
|
||||
|
||||
bool wait(handle_t h) {
|
||||
if (h == invalid()) return false;
|
||||
::printf("wait...\n");
|
||||
if (::pthread_mutex_lock(&mutex_) != 0) {
|
||||
return false;
|
||||
}
|
||||
@ -90,11 +91,13 @@ public:
|
||||
|
||||
void notify(handle_t h) {
|
||||
if (h == invalid()) return;
|
||||
::printf("notify...\n");
|
||||
::pthread_cond_signal(&cond_);
|
||||
}
|
||||
|
||||
void broadcast(handle_t h) {
|
||||
if (h == invalid()) return;
|
||||
::printf("broadcast...\n");
|
||||
::pthread_cond_broadcast(&cond_);
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
namespace ipc {
|
||||
namespace detail {
|
||||
|
||||
class waiter_impl {
|
||||
class waiter_wrapper {
|
||||
public:
|
||||
using waiter_t = detail::waiter;
|
||||
|
||||
@ -20,12 +20,12 @@ private:
|
||||
waiter_t::handle_t h_ = waiter_t::invalid();
|
||||
|
||||
public:
|
||||
waiter_impl() = default;
|
||||
explicit waiter_impl(waiter_t* w) {
|
||||
waiter_wrapper() = default;
|
||||
explicit waiter_wrapper(waiter_t* w) {
|
||||
attach(w);
|
||||
}
|
||||
waiter_impl(const waiter_impl&) = delete;
|
||||
waiter_impl& operator=(const waiter_impl&) = delete;
|
||||
waiter_wrapper(const waiter_wrapper&) = delete;
|
||||
waiter_wrapper& operator=(const waiter_wrapper&) = delete;
|
||||
|
||||
waiter_t * waiter() { return w_; }
|
||||
waiter_t const * waiter() const { return w_; }
|
||||
@ -15,15 +15,15 @@
|
||||
#include "shm.h"
|
||||
#include "rw_lock.h"
|
||||
|
||||
#include "platform/waiter.h"
|
||||
#include "platform/waiter_wrapper.h"
|
||||
|
||||
namespace ipc {
|
||||
namespace detail {
|
||||
|
||||
class queue_waiter {
|
||||
protected:
|
||||
ipc::detail::waiter_impl waiter_;
|
||||
ipc::detail::waiter_impl cc_waiter_;
|
||||
ipc::detail::waiter_wrapper waiter_;
|
||||
ipc::detail::waiter_wrapper cc_waiter_;
|
||||
|
||||
bool connected_ = false;
|
||||
bool dismiss_ = true;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "def.h"
|
||||
#include "platform/waiter.h"
|
||||
#include "platform/waiter_wrapper.h"
|
||||
|
||||
namespace ipc {
|
||||
|
||||
@ -11,7 +11,7 @@ class waiter::waiter_ : public pimpl<waiter_> {
|
||||
public:
|
||||
std::string n_;
|
||||
|
||||
detail::waiter_impl w_ { new detail::waiter };
|
||||
detail::waiter_wrapper w_ { new detail::waiter };
|
||||
~waiter_() { delete w_.waiter(); }
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user