mardi 31 mars 2015

I need std::chrono::high_resolution_clock::time_point field which I want to write from one thread and read from another thread. If I declare it as is my code compiles without any errors.


But to make my field visible in another thread I surround it with std::atomic like this std::atomic<std::chrono::high_resolution_clock::time_point> and now I have following compilation error:



/usr/include/c++/4.8/atomic:167:7: error: function ‘std::atomic<_Tp>::atomic() [with _Tp = std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1l, 1000000000l> > >]’ defaulted on its first declaration with an exception-specification that differs from the implicit declaration ‘constexpr std::atomic<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1l, 1000000000l> > > >::atomic()’
atomic() noexcept = default;


How should I declare std::chrono::high_resolution_clock::time_point field which I write from one thread and read from another (to make sure that "reading thread" sees last value)?


Aucun commentaire:

Enregistrer un commentaire