diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c783279..04f4d10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Boost REQUIRED COMPONENTS date_time exception filesystem log system) +find_package(Boost REQUIRED COMPONENTS date_time exception filesystem log) find_package(ICU REQUIRED COMPONENTS uc) find_package(JsonCpp REQUIRED) if(WITH_DCMTK) diff --git a/src/odil/Association.cpp b/src/odil/Association.cpp index 0735904..d444164 100644 --- a/src/odil/Association.cpp +++ b/src/odil/Association.cpp @@ -46,8 +46,8 @@ ::Association() _transfer_syntaxes_by_abstract_syntax(), _transfer_syntaxes_by_id(), _next_message_id(1) { - this->set_tcp_timeout(boost::posix_time::pos_infin); - this->set_message_timeout(boost::posix_time::seconds(30)); + this->set_tcp_timeout(std::chrono::nanoseconds::max()); + this->set_message_timeout(std::chrono::seconds(30)); } Association diff --git a/src/odil/MoveSCU.cpp b/src/odil/MoveSCU.cpp index ade1367..50bb85e 100644 --- a/src/odil/MoveSCU.cpp +++ b/src/odil/MoveSCU.cpp @@ -104,7 +104,7 @@ ::_move( while(!done) { // Use a small timeout to avoid blocking for a long time. - boost::posix_time::milliseconds const timeout(10); + std::chrono::milliseconds timeout(10); store_association.set_tcp_timeout(timeout); store_association.set_message_timeout(timeout); diff --git a/src/odil/dul/StateMachine.cpp b/src/odil/dul/StateMachine.cpp index a22ea2b..ebb5f3d 100644 --- a/src/odil/dul/StateMachine.cpp +++ b/src/odil/dul/StateMachine.cpp @@ -265,7 +265,7 @@ ::start_timer(EventData & data) return; - auto const canceled = this->_artim_timer.expires_from_now(this->_timeout); + auto const canceled = this->_artim_timer.expires_after(this->_timeout); if(canceled != 0) { throw Exception("ARTIM timer started with pending operations"); @@ -300,7 +300,7 @@ ::stop_timer() return; - this->_artim_timer.expires_at(boost::posix_time::pos_infin); + this->_artim_timer.expires_at(boost::asio::steady_timer::time_point::max()); this->_transport.get_service().poll(); // FIXME: check that the timer was aborted /* diff --git a/src/odil/dul/StateMachine.h b/src/odil/dul/StateMachine.h index f45688a..5d0f116 100644 --- a/src/odil/dul/StateMachine.h +++ b/src/odil/dul/StateMachine.h @@ -64,7 +64,7 @@ class ODIL_API StateMachine }; /// @brief Duration of the timeout. - typedef boost::asio::deadline_timer::duration_type duration_type; + typedef std::chrono::nanoseconds duration_type; /// @brief Constructor, initializing to Sta1. StateMachine(); @@ -156,7 +156,7 @@ class ODIL_API StateMachine duration_type _timeout; /// @brief Association Request/Reject/Release Timer. - boost::asio::deadline_timer _artim_timer; + boost::asio::steady_timer _artim_timer; /// @brief Callback checking whether an association request is acceptable. AssociationAcceptor _association_acceptor; diff --git a/src/odil/dul/Transport.cpp b/src/odil/dul/Transport.cpp index d988330..789b4fa 100644 --- a/src/odil/dul/Transport.cpp +++ b/src/odil/dul/Transport.cpp @@ -235,7 +235,7 @@ void Transport ::_start_deadline(Source & source, boost::system::error_code & error) { - auto const canceled = this->_deadline.expires_from_now(this->_timeout); + auto const canceled = this->_deadline.expires_after(this->_timeout); if(canceled != 0) { throw Exception("TCP timer started with pending operations"); @@ -254,7 +254,7 @@ void Transport ::_stop_deadline() { - this->_deadline.expires_at(boost::posix_time::pos_infin); + this->_deadline.expires_at(boost::asio::steady_timer::time_point::max()); } void diff --git a/src/odil/dul/Transport.h b/src/odil/dul/Transport.h index 6a0ef23..4c30895 100644 --- a/src/odil/dul/Transport.h +++ b/src/odil/dul/Transport.h @@ -47,7 +47,7 @@ struct ODIL_API Transport typedef boost::asio::ip::tcp::socket Socket; /// @brief Duration of the timeout. - typedef boost::asio::deadline_timer::duration_type duration_type; + typedef std::chrono::steady_clock::duration duration_type; /// @brief Constructor. Transport(); @@ -98,7 +98,7 @@ struct ODIL_API Transport boost::asio::io_service _service; std::shared_ptr _socket; duration_type _timeout; - boost::asio::deadline_timer _deadline; + boost::asio::steady_timer _deadline; std::shared_ptr _acceptor; diff --git a/tests/code/EchoSCP.cpp b/tests/code/EchoSCP.cpp index ccf81da..f2bdc2a 100644 --- a/tests/code/EchoSCP.cpp +++ b/tests/code/EchoSCP.cpp @@ -23,7 +23,7 @@ struct Status void run_server(Status * status) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/tests/code/FindSCP.cpp b/tests/code/FindSCP.cpp index 8024b32..9929d28 100644 --- a/tests/code/FindSCP.cpp +++ b/tests/code/FindSCP.cpp @@ -79,7 +79,7 @@ class Generator: public odil::SCP::DataSetGenerator void run_server(Status * status) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/tests/code/GetSCP.cpp b/tests/code/GetSCP.cpp index ed6a368..936b2a8 100644 --- a/tests/code/GetSCP.cpp +++ b/tests/code/GetSCP.cpp @@ -91,7 +91,7 @@ class Generator: public odil::GetSCP::DataSetGenerator void run_server(Status * status) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/tests/code/MoveSCP.cpp b/tests/code/MoveSCP.cpp index f3189e2..3d44afc 100644 --- a/tests/code/MoveSCP.cpp +++ b/tests/code/MoveSCP.cpp @@ -121,7 +121,7 @@ class Generator: public odil::MoveSCP::DataSetGenerator void run_server(Status * status) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/tests/code/NCreateSCP.cpp b/tests/code/NCreateSCP.cpp index 348e389..b46b2cf 100644 --- a/tests/code/NCreateSCP.cpp +++ b/tests/code/NCreateSCP.cpp @@ -23,7 +23,7 @@ struct Status void run_server(Status * status) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/tests/code/SCPDispatcher.cpp b/tests/code/SCPDispatcher.cpp index 747ad2a..5fafb4c 100644 --- a/tests/code/SCPDispatcher.cpp +++ b/tests/code/SCPDispatcher.cpp @@ -22,7 +22,7 @@ struct Status void run_server(Status * status, bool with_echo) { odil::Association association; - association.set_tcp_timeout(boost::posix_time::seconds(1)); + association.set_tcp_timeout(std::chrono::seconds(1)); try { diff --git a/wrappers/python/Association.cpp b/wrappers/python/Association.cpp index 701c2cd..ab4fe85 100644 --- a/wrappers/python/Association.cpp +++ b/wrappers/python/Association.cpp @@ -33,13 +33,13 @@ void receive_association( float get_tcp_timeout(odil::Association const& association) { - return association.get_tcp_timeout().total_microseconds()/1000000.f; + return std::chrono::duration_cast(association.get_tcp_timeout()).count() / 1000000.f; + } void set_tcp_timeout(odil::Association& association, float seconds) { - association.set_tcp_timeout( - boost::posix_time::microseconds(int(seconds*1000000.f))); + association.set_tcp_timeout(std::chrono::microseconds(int(seconds*1000000.f))); } }