Skip to content

Commit

Permalink
Use bool instead of void as return type in packaged_task.
Browse files Browse the repository at this point in the history
MSVC can not handle void as return type, so we use a dummy bool instead.
Fixes #32.
  • Loading branch information
joto committed Aug 20, 2014
1 parent ec037bd commit 7ec968e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/osmium/io/detail/read_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace osmium {
m_done(done) {
}

void operator()() {
bool operator()() {
osmium::thread::set_thread_name("_osmium_input");

try {
Expand All @@ -91,6 +91,7 @@ namespace osmium {
m_queue.push(std::string());
throw;
}
return true;
}

}; // class ReadThread
Expand Down
3 changes: 2 additions & 1 deletion include/osmium/io/detail/write_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace osmium {
m_compressor(compressor) {
}

void operator()() {
bool operator()() {
osmium::thread::set_thread_name("_osmium_output");

std::future<std::string> data_future;
Expand All @@ -72,6 +72,7 @@ namespace osmium {
} while (!data.empty());

m_compressor->close();
return true;
}

}; // class WriteThread
Expand Down
3 changes: 2 additions & 1 deletion include/osmium/io/detail/xml_input_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace osmium {
m_done(done) {
}

void operator()() {
bool operator()() {
XML_Parser parser = XML_ParserCreate(nullptr);
if (!parser) {
throw osmium::io_error("Internal error: Can not create parser");
Expand Down Expand Up @@ -240,6 +240,7 @@ namespace osmium {
// intentionally left blank
}
XML_ParserFree(parser);
return true;
}

private:
Expand Down
4 changes: 2 additions & 2 deletions include/osmium/thread/checked_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ namespace osmium {
class CheckedTask {

std::thread m_thread;
std::future<void> m_future;
std::future<bool> m_future;

public:

template <class... TArgs>
explicit CheckedTask(TArgs&&... args) {
std::packaged_task<void()> pack_task(T(std::forward<TArgs>(args)...));
std::packaged_task<bool()> pack_task(T(std::forward<TArgs>(args)...));
m_future = pack_task.get_future();
m_thread = std::thread(std::move(pack_task));
}
Expand Down

0 comments on commit 7ec968e

Please sign in to comment.