GithubHelp home page GithubHelp logo

Comments (11)

joto avatar joto commented on July 23, 2024

The proposed solution at alex85k/libosmium@b397605 will not work.

Basically the problem is that a buffer needs to be moved into the *OutputBlock class and when the object is copied where does the Buffer go?

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

I had a bad feeling about that buffer :) Currently the buffer is re-created, I guess. If we move the buffer or copy the pointer, can we guarantee that the objects will work as desired? I am completely new to move-constructors and had used only the trivial (primitive-type) cases of copy-constructors...

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

Maybe this is the bug described in
http://stackoverflow.com/questions/11768273/why-cant-c11-move-a-noncopyable-functor-to-a-stdfunction
(only Visual Studio compiler wants to have copyable object for casting it into function)

/outdated/

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

http://stackoverflow.com/questions/16639131/can-stdfunction-be-move-constructed-from-rvalue-reference-to-a-temporary-funct

So, it seems that all functors should be copyable to be used as std::functions?
(Too C++-ish... So that is the reason why Java abandoned type conversions and operation overloadind :) )

/outdated/

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

New info:

That is not a copy-constructor problem, that is just the same packaged_task<void()> compiler bug-or-feature!

Close looking at the error:

                std::packaged_task<result_type()> task(std::move(f));

2>          D:\build_d\libosmium7\include\osmium/thread/pool.hpp(167) : see reference to function template instantiation 'std::packaged_task<result_type (void)>::packaged_task<osmium::io::detail::XMLOutputBlock>(_Fty2 &&)' being compiled

from libosmium.

joto avatar joto commented on July 23, 2024

Yes, as far as I can tell this is the same issue we had with XMLParser. packaged_task uses std::function internally and that needs a copyable functor on Windows. It works with a movable functor on Linux/OSX. Unfortunately the bug fix for XMLParser for Windows broke the OSX compile and I don't know why. So this is a complicated problem and needs more looking into.

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

Here is the alternative fix:
alex85k@5318c1f
It compiles, however, I do no believe it works as needed :)

from libosmium.

joto avatar joto commented on July 23, 2024

Your code creates a dangling reference. Can you verify my commit works?

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

Yes, it works! Thank you for another demonstration of C++ magic :)

from libosmium.

alex85k avatar alex85k commented on July 23, 2024

Should the solution for #32 (reference) (already added copy-constructor in the same situation) be the same or copying is really needed there?

from libosmium.

joto avatar joto commented on July 23, 2024

For #32 the solution is reasonably clean, so it should be kept that way. The fix for OPLOutputBlock and XMLOutputBlock is somewhat icky because it adds another redirection that should really not be necessary. But it was the simplest and cleanest I could come up with at the moment. There are some other problems with the threading code so I have to look at that code again anyway, maybe I can come up with a cleaner solution then.

from libosmium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.