lichao
2021-06-03 b674aecae951c1f83e07f80956160fadf331d026
remove useless code, compile warning.
3个文件已修改
69 ■■■■■ 已修改文件
src/bh_util.h 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/timed_queue.h 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/topic_node.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/bh_util.h
@@ -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_;