@@ -126,6 +126,7 @@ namespace osmium {
126126 osmium::thread::thread_handler m_thread{};
127127
128128 std::size_t m_file_size = 0 ;
129+ std::atomic<std::size_t > m_offset{0 };
129130
130131 osmium::osm_entity_bits::type m_read_which_entities = osmium::osm_entity_bits::all;
131132 osmium::io::read_meta m_read_metadata = osmium::io::read_meta::yes;
@@ -159,6 +160,7 @@ namespace osmium {
159160 detail::future_string_queue_type& input_queue,
160161 detail::future_buffer_queue_type& osmdata_queue,
161162 std::promise<osmium::io::Header>&& header_promise,
163+ std::atomic<std::size_t >* offset_ptr,
162164 osmium::osm_entity_bits::type read_which_entities,
163165 osmium::io::read_meta read_metadata,
164166 osmium::io::buffers_type buffers_kind,
@@ -170,6 +172,7 @@ namespace osmium {
170172 input_queue,
171173 osmdata_queue,
172174 promise,
175+ offset_ptr,
173176 read_which_entities,
174177 read_metadata,
175178 buffers_kind,
@@ -319,7 +322,7 @@ namespace osmium {
319322 m_read_thread_manager(*m_decompressor, m_input_queue),
320323 m_osmdata_queue(detail::get_osmdata_queue_size(), "parser_results"),
321324 m_osmdata_queue_wrapper(m_osmdata_queue),
322- m_file_size(m_decompressor->file_size ()) {
325+ m_file_size(m_decompressor->is_real () ? m_decompressor-> file_size() : osmium::file_size(m_fd )) {
323326
324327 (void )std::initializer_list<int >{
325328 (set_option (args), 0 )...
@@ -340,7 +343,7 @@ namespace osmium {
340343 const int fd_for_parser = m_decompressor->is_real () ? -1 : m_fd;
341344 m_thread = osmium::thread::thread_handler{parser_thread, std::ref (*m_pool), fd_for_parser, std::ref (m_creator),
342345 std::ref (m_input_queue), std::ref (m_osmdata_queue),
343- std::move (header_promise), m_read_which_entities,
346+ std::move (header_promise), &m_offset, m_read_which_entities,
344347 m_read_metadata, m_buffers_kind,
345348 m_decompressor->want_buffered_pages_removed ()};
346349 }
@@ -518,7 +521,10 @@ namespace osmium {
518521 * do an expensive system call.
519522 */
520523 std::size_t offset () const noexcept {
521- return m_decompressor->offset ();
524+ if (m_decompressor->is_real ()) {
525+ return m_decompressor->offset ();
526+ }
527+ return m_offset;
522528 }
523529
524530 }; // class Reader
0 commit comments