/** * Dump operations tracked * * @return Vector of trace information in string */ std::vector<std::string> DumpAll() const { std::vector<std::string> ret; { uint64_t end_cnt = gcnt_; { MUTEX_LOCK_GUARD(data_mutex_); BOOST_FOREACH(const ThreadInfo* info, th_info_set_) { end_cnt = std::min(end_cnt, info->cnt.load(boost::memory_order_acquire)); } } boost::scoped_array<TraceInfo> clone(new TraceInfo[ring_buf_size]); for (unsigned i = 0; i < ring_buf_size; ++i) clone[i] = logs_[i]; uint64_t start_cnt = gcnt_; start_cnt = start_cnt > ring_buf_size ? start_cnt - ring_buf_size : 0; { for (uint64_t pos = start_cnt; pos < end_cnt; ++pos) { TraceInfo ti = clone[pos % ring_buf_size]; struct tm time_ret; char time_str[64]; time_t time_added = ti.time_added; localtime_r(&time_added, &time_ret); strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", &time_ret); std::string msg; msg = (boost::format("%s %s %s() inode: %d, client: %d") % boost::lexical_cast<std::string>(ti.th_id) % time_str % reinterpret_cast<const char*>(ti.method.load()) % ti.inode % ti.client).str(); ret.push_back(msg); } } }
inline void move_up(node_type node) { MUTEX_LOCK_GUARD(mtx, normal_lock); if(!in_queue(node)) return; QUEUE_DEFINE_INTRUSIVE_MOVE_UP(); }
inline size_t pop_tail_half(T **buffer, const size_t max, const queue_id_t new_state) { MUTEX_LOCK_GUARD(mtx, normal_lock); size_t half = std::min(max, total / 2); if(half == 0) return 0; for(size_t i(0); i < half; ++i) { buffer[i] = head; __INTRUSIVE_QUEUE(head) = new_state; LOG_NORMAL_OPERATION(); head = (node_type)__INTRUSIVE_NEXT(head); } // head will not be nullptr here. assert(head != nullptr); __INTRUSIVE_PREV(head) = nullptr; total -= half; return half; }
void BaseInodeSrc::SetLastUsed(InodeNum inode) { MUTEX_LOCK_GUARD(data_mutex_); last_used_ = inode; Persist_(); }
InodeNum BaseInodeSrc::GetLastUsed() { MUTEX_LOCK_GUARD(data_mutex_); return last_used_; }
inline void push_head(node_type data) { MUTEX_LOCK_GUARD(mtx, normal_lock); push_head_node(data); }
inline bool pop_tail(node_type& data, const queue_id_t new_state) { MUTEX_LOCK_GUARD(mtx, normal_lock); QUEUE_DEFINE_INTRUSIVE_DOUBLE_POP_TAIL(); }
inline bool pop_head(node_type& data, const queue_id_t new_state) { MUTEX_LOCK_GUARD(mtx, normal_lock); return do_pop_head(data, new_state); }
inline bool pop_if_not_empty(node_type& data, const queue_id_t new_state) { MUTEX_LOCK_GUARD(mtx, normal_lock); QUEUE_DEFINE_INTRUSIVE_DOUBLE_POP_IF_NOT_EMPTY(); }