File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ namespace osmium {
9090
9191 class Decompressor {
9292
93- std::atomic<std::size_t > m_offset{ 0 };
93+ std::atomic<std::size_t >* m_offset_ptr{ nullptr };
9494
9595 std::atomic_bool m_want_buffered_pages_removed{false };
9696
@@ -118,12 +118,14 @@ namespace osmium {
118118 return true ;
119119 }
120120
121- std::size_t offset () const noexcept {
122- return m_offset ;
121+ void set_offset_ptr ( std::atomic<std:: size_t >* offset_ptr) noexcept {
122+ m_offset_ptr = offset_ptr ;
123123 }
124124
125125 void set_offset (const std::size_t offset) noexcept {
126- m_offset = offset;
126+ if (m_offset_ptr) {
127+ *m_offset_ptr = offset;
128+ }
127129 }
128130
129131 bool want_buffered_pages_removed () const noexcept {
Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ namespace osmium {
257257 return fd;
258258 }
259259
260- static std::unique_ptr<Decompressor> make_decompressor (const osmium::io::File& file, int fd) {
260+ std::unique_ptr<Decompressor> make_decompressor (const osmium::io::File& file, int fd) {
261261 const auto & factory = osmium::io::CompressionFactory::instance ();
262262 if (file.buffer ()) {
263263 return factory.create_decompressor (file.compression (), file.buffer (), file.buffer_size ());
@@ -332,6 +332,8 @@ namespace osmium {
332332 m_pool = &thread::Pool::default_instance ();
333333 }
334334
335+ m_decompressor->set_offset_ptr (&m_offset);
336+
335337 std::promise<osmium::io::Header> header_promise;
336338 m_header_future = header_promise.get_future ();
337339
@@ -521,9 +523,6 @@ namespace osmium {
521523 * do an expensive system call.
522524 */
523525 std::size_t offset () const noexcept {
524- if (m_decompressor->is_real ()) {
525- return m_decompressor->offset ();
526- }
527526 return m_offset;
528527 }
529528
You can’t perform that action at this time.
0 commit comments