Skip to content

Commit

Permalink
add inline method, refactoring collector
Browse files Browse the repository at this point in the history
- add comments
- add protected place and virtual handler
  • Loading branch information
fullincome committed Oct 15, 2019
1 parent bdca3f7 commit 9fb1ff4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ inline size_t RingBuffer::size()
return buffer_.size();
}

bool RingBuffer::is_empty()
inline bool RingBuffer::is_empty()
{
return read_pos_ == write_pos_;
}
Expand Down Expand Up @@ -267,14 +267,16 @@ inline size_t RingBuffer::pop_front(std::string &dest)
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++






// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Collector - обертка, которая управляет кольцевым буфером.
// Thread safe, за исключением set_size() и set_callback(),
// предполагается однократный вызов этих функций на этапе инициализации.
/*
* Collector - RingBuffer wrapper.
* Thread safe, except set_size() and set_callback(),
* a single call both function is expected at the initialization stage.
*/

/*
* For more custom handler() use inheritance and override that.
*/
#define READ_TIMEOUT_MS 3000
class Collector
{
Expand All @@ -284,8 +286,10 @@ class Collector
RingBuffer buffer_;
collector_callback _call_back;

protected:
size_t get_size();
void handler();
virtual void handler();

public:
Collector();
Collector(size_t size);
Expand Down Expand Up @@ -465,7 +469,7 @@ inline bool Collector::start()
}

}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


#endif // COLLECTOR_HPP

0 comments on commit 9fb1ff4

Please sign in to comment.