Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "pure virtual method called" in kafka_source #34

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion include/kspp/sources/kafka_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace kspp {
}

void start(int64_t offset) override {
_thread = std::thread(&kafka_source_base::thread_f, this);
_impl.start(offset);
_started = true;
}
Expand Down Expand Up @@ -92,7 +93,7 @@ namespace kspp {
: partition_source<K, V>(nullptr, partition)
, _started(false)
, _exit(false)
, _thread(&kafka_source_base::thread_f, this)
, _thread_f_finished(false)
, _impl(config, topic, partition, consumer_group)
, _key_codec(key_codec)
, _val_codec(val_codec)
Expand Down Expand Up @@ -163,12 +164,14 @@ namespace kspp {
_commit_chain_size.set(_commit_chain.size());
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
_thread_f_finished = true;
DLOG(INFO) << "exiting thread";
}

size_t _max_incomming_queue_size=1000;
bool _started;
bool _exit;
bool _thread_f_finished;
std::thread _thread;
event_queue<K, V> _incomming_msg;
kafka_consumer _impl;
Expand Down Expand Up @@ -212,6 +215,12 @@ namespace kspp {
key_codec,
val_codec) {
}

~kafka_source() override
{
while (!this->_thread_f_finished)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

protected:
std::shared_ptr<kevent<K, V>> parse(const std::unique_ptr<RdKafka::Message> &ref) override {
Expand Down Expand Up @@ -295,6 +304,12 @@ namespace kspp {
val_codec) {
}

~kafka_source() override
{
while (!this->_thread_f_finished)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

protected:
std::shared_ptr<kevent<void, V>> parse(const std::unique_ptr<RdKafka::Message> &ref) override {
if (!ref)
Expand Down Expand Up @@ -353,6 +368,12 @@ namespace kspp {
nullptr) {
}

~kafka_source() override
{
while (!this->_thread_f_finished)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

protected:
std::shared_ptr<kevent<K, void>> parse(const std::unique_ptr<RdKafka::Message> &ref) override {
if (!ref || ref->key_len() == 0)
Expand Down