lichao
2021-06-03 b674aecae951c1f83e07f80956160fadf331d026
remove useless code, compile warning.
3个文件已修改
97 ■■■■ 已修改文件
src/bh_util.h 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/timed_queue.h 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/topic_node.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/bh_util.h
@@ -41,8 +41,8 @@
inline void Put16(void *p, uint16_t u)
{
    auto ptr = static_cast<uint8_t *>(p);
    ptr[0] = (uint8_t)(u >> 8u);
    ptr[1] = (uint8_t)(u);
    ptr[0] = (uint8_t) (u >> 8u);
    ptr[1] = (uint8_t) (u);
}
inline uint32_t Get32(const void *p)
@@ -56,10 +56,10 @@
inline void Put32(void *p, uint32_t u)
{
    auto ptr = static_cast<uint8_t *>(p);
    ptr[0] = (uint8_t)(u >> 24u);
    ptr[1] = (uint8_t)(u >> 16u);
    ptr[2] = (uint8_t)(u >> 8u);
    ptr[3] = (uint8_t)(u);
    ptr[0] = (uint8_t) (u >> 24u);
    ptr[1] = (uint8_t) (u >> 16u);
    ptr[2] = (uint8_t) (u >> 8u);
    ptr[3] = (uint8_t) (u);
}
inline uint64_t Get64(const void *p)
@@ -77,14 +77,14 @@
inline void Put64(void *p, uint64_t u)
{
    auto ptr = static_cast<uint8_t *>(p);
    ptr[0] = (uint8_t)(u >> 56);
    ptr[1] = (uint8_t)(u >> 48);
    ptr[2] = (uint8_t)(u >> 40u);
    ptr[3] = (uint8_t)(u >> 32);
    ptr[4] = (uint8_t)(u >> 24u);
    ptr[5] = (uint8_t)(u >> 16u);
    ptr[6] = (uint8_t)(u >> 8u);
    ptr[7] = (uint8_t)(u);
    ptr[0] = (uint8_t) (u >> 56);
    ptr[1] = (uint8_t) (u >> 48);
    ptr[2] = (uint8_t) (u >> 40u);
    ptr[3] = (uint8_t) (u >> 32);
    ptr[4] = (uint8_t) (u >> 24u);
    ptr[5] = (uint8_t) (u >> 16u);
    ptr[6] = (uint8_t) (u >> 8u);
    ptr[7] = (uint8_t) (u);
}
inline void PutInt(void *p, uint8_t u) { Put8(p, u); }
@@ -143,31 +143,6 @@
    {
        Lock lk(mutex_);
        return f(data_);
    }
};
template <class T, class Tag>
class StaticDataRef
{
    typedef T *Ptr;
    static inline Ptr &ptr()
    {
        static Ptr sp(nullptr);
        return sp;
    }
protected:
    static inline T &GetData(const std::string &msg = "Must set data before use!")
    {
        if (!ptr()) { throw std::logic_error(msg); }
        return *ptr();
    }
public:
    static bool SetData(T &t)
    {
        auto Bind = [&]() { ptr() = &t; return true; };
        return ptr() ? false : Bind();
    }
};
src/timed_queue.h
@@ -45,46 +45,4 @@
    Data data_;
};
template <class Data, class ClockType = std::chrono::steady_clock>
class TimedQueue
{
    typedef TimedData<Data, ClockType> Record;
public:
    typedef typename Record::Clock Clock;
    typedef typename Record::TimePoint TimePoint;
    typedef typename Record::Duration Duration;
private:
    typedef std::list<Record> Queue;
    Synced<Queue> queue_;
public:
    void Push(Data &&data, const TimePoint &expire) { queue_->emplace_back(expire, std::move(data)); }
    void Push(Data const &data, const TimePoint &expire) { queue_->emplace_back(expire, data); }
    void Push(Data &&data, Duration const &timeout) { Push(std::move(data), Clock::now() + timeout); }
    void Push(Data const &data, Duration const &timeout) { Push(data, Clock::now() + timeout); }
    template <class Func>
    void CheckAll(Func const &func)
    {
        queue_.Apply([&](Queue &q) {
            if (q.empty()) {
                return;
            }
            auto it = q.begin();
            do {
                if (it->Expired()) {
                    it = q.erase(it);
                } else if (func(it->data())) {
                    it = q.erase(it);
                } else {
                    ++it;
                }
            } while (it != q.end());
        });
    }
};
#endif // end of include guard: TIMED_QUEUE_Y2YLRBS3
src/topic_node.h
@@ -163,8 +163,8 @@
    bool Init();
    bool Valid() const { return state() != eStateUninited; }
    std::mutex mutex_;
    MQId ssn_id_ = 0;
    std::atomic<State> state_;
    MQId ssn_id_ = 0;
    int proc_index_ = -1;
    TopicQueryCache topic_query_cache_;