mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2026-01-01 03:12:13 +08:00
refactor(log): replace utility/log with imp/log in prod_cons.h and queue.h
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h" - prod_cons.h: Replace ipc::log() calls with LIBIPC_LOG() + log.warning() - Updated 2 force_push() template functions in broadcast implementations - Changed log level from generic log to warning for force_push scenarios - queue.h: Replace ipc::error() calls with LIBIPC_LOG() + log.error() - Updated queue_conn::open() template function - Use type-safe streaming interface instead of printf-style formatting - Remove manual newline characters from log messages
This commit is contained in:
parent
2ec1914691
commit
bf62216e8d
@ -10,7 +10,7 @@
|
||||
|
||||
#include "libipc/platform/detail.h"
|
||||
#include "libipc/circ/elem_def.h"
|
||||
#include "libipc/utility/log.h"
|
||||
#include "libipc/imp/log.h"
|
||||
#include "libipc/utility/utility.h"
|
||||
|
||||
namespace ipc {
|
||||
@ -242,6 +242,7 @@ struct prod_cons_impl<wr<relat::single, relat::multi, trans::broadcast>> {
|
||||
|
||||
template <typename W, typename F, typename E>
|
||||
bool force_push(W* wrapper, F&& f, E* elems) {
|
||||
LIBIPC_LOG();
|
||||
E* el;
|
||||
epoch_ += ep_incr;
|
||||
for (unsigned k = 0;;) {
|
||||
@ -252,7 +253,7 @@ struct prod_cons_impl<wr<relat::single, relat::multi, trans::broadcast>> {
|
||||
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
||||
circ::cc_t rem_cc = cur_rc & ep_mask;
|
||||
if (cc & rem_cc) {
|
||||
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
|
||||
log.warning("force_push: k = ", k, ", cc = ", cc, ", rem_cc = ", rem_cc);
|
||||
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
|
||||
if (cc == 0) return false; // no reader
|
||||
}
|
||||
@ -375,7 +376,7 @@ struct prod_cons_impl<wr<relat::multi, relat::multi, trans::broadcast>> {
|
||||
auto cur_rc = el->rc_.load(std::memory_order_acquire);
|
||||
circ::cc_t rem_cc = cur_rc & rc_mask;
|
||||
if (cc & rem_cc) {
|
||||
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
|
||||
log.warning("force_push: k = ", k, ", cc = ", cc, ", rem_cc = ", rem_cc);
|
||||
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
|
||||
if (cc == 0) return false; // no reader
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include "libipc/shm.h"
|
||||
#include "libipc/rw_lock.h"
|
||||
|
||||
#include "libipc/utility/log.h"
|
||||
#include "libipc/imp/log.h"
|
||||
#include "libipc/platform/detail.h"
|
||||
#include "libipc/circ/elem_def.h"
|
||||
#include "libipc/mem/resource.h"
|
||||
@ -30,8 +30,9 @@ protected:
|
||||
|
||||
template <typename Elems>
|
||||
Elems* open(char const * name) {
|
||||
LIBIPC_LOG();
|
||||
if (!is_valid_string(name)) {
|
||||
ipc::error("fail open waiter: name is empty!\n");
|
||||
log.error("fail open waiter: name is empty!");
|
||||
return nullptr;
|
||||
}
|
||||
if (!elems_h_.acquire(name, sizeof(Elems))) {
|
||||
@ -39,7 +40,7 @@ protected:
|
||||
}
|
||||
auto elems = static_cast<Elems*>(elems_h_.get());
|
||||
if (elems == nullptr) {
|
||||
ipc::error("fail acquire elems: %s\n", name);
|
||||
log.error("fail acquire elems: ", name);
|
||||
return nullptr;
|
||||
}
|
||||
elems->init();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user