Skip to content

Commit d534d95

Browse files
committed
Fixed comilation.
1 parent 4592dca commit d534d95

8 files changed

Lines changed: 18 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ if (NOT EMBEDDED_RESTC_CPP)
260260
endif()
261261

262262
find_package(Boost ${RESTC_BOOST_VERSION} REQUIRED ${restc_cpp_boost_find_config} COMPONENTS
263-
system
264263
program_options
265264
filesystem
266265
date_time

include/restc-cpp/IoTimer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ class IoTimer : public std::enable_shared_from_this<IoTimer>
145145

146146
void Start(int millisecondsTimeOut)
147147
{
148-
timer_.expires_from_now(
149-
boost::posix_time::milliseconds(millisecondsTimeOut));
148+
timer_.expires_after(std::chrono::milliseconds{millisecondsTimeOut});
150149
is_active_ = true;
151150
try {
152151
timer_.async_wait(std::bind(
@@ -162,7 +161,7 @@ class IoTimer : public std::enable_shared_from_this<IoTimer>
162161
bool is_active_ = false;
163162
bool is_expiered_ = false;
164163
close_t close_;
165-
boost::asio::deadline_timer timer_;
164+
boost::asio::steady_timer timer_;
166165
const std::string timer_name_;
167166
};
168167

include/restc-cpp/restc-cpp.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,14 @@ class Context {
335335
/*! Asynchronously sleep for a period */
336336
template<class Rep, class Period>
337337
void Sleep(const std::chrono::duration<Rep, Period>& duration) {
338-
const auto microseconds =
338+
const uint64_t microseconds =
339339
std::chrono::duration_cast<std::chrono::microseconds>(
340340
duration).count();
341-
::boost::posix_time::microseconds ms(microseconds);
342-
Sleep(ms);
341+
Sleep(microseconds);
343342
}
344343

345344
/*! Asynchronously sleep for a period */
346-
virtual void Sleep(const ::boost::posix_time::microseconds& ms) = 0;
345+
virtual void Sleep(const uint64_t microseconds) = 0;
347346

348347
static std::unique_ptr<Context>
349348
Create(::boost::asio::yield_context& yield,

src/ConnectionPoolImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ class ConnectionPoolImpl
250250
private:
251251
void ScheduleNextCacheCleanup() {
252252
LOCK_ALWAYS_;
253-
cache_cleanup_timer_.expires_from_now(
254-
boost::posix_time::seconds(properties_->cacheCleanupIntervalSeconds));
253+
cache_cleanup_timer_.expires_after(
254+
std::chrono::seconds(properties_->cacheCleanupIntervalSeconds));
255255
cache_cleanup_timer_.async_wait([capture0 = shared_from_this()](auto &&PH1) {
256256
capture0->OnCacheCleanup(std::forward<decltype(PH1)>(PH1));
257257
});
@@ -452,7 +452,7 @@ class ConnectionPoolImpl
452452
#endif
453453
const Request::Properties::ptr_t properties_;
454454
ConnectionWrapper::release_callback_t on_release_;
455-
boost::asio::deadline_timer cache_cleanup_timer_;
455+
boost::asio::steady_timer cache_cleanup_timer_;
456456

457457
mutable std::mutex mutex_;
458458
}; // ConnectionPoolImpl

src/RestClientImpl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ class RestClientImpl final : public RestClient {
113113
return req.Execute(*this);
114114
}
115115

116-
void Sleep(const boost::posix_time::microseconds& ms) override {
117-
boost::asio::deadline_timer timer(
116+
void Sleep(const uint64_t microseconds) override {
117+
boost::asio::steady_timer timer(
118118
GetClient().GetIoService(),
119-
boost::posix_time::microseconds(ms));
120-
119+
boost::asio::chrono::microseconds(microseconds));
121120
timer.async_wait(GetYield());
122121
}
123122

tests/functional/CRUD_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ TEST(CRUD, Crud) {
6767
// Get the reply before we validate the operation. Else it may run in parallel
6868
reply->fetchAndIgnore();
6969

70+
// This test fails randomly on fast machines.
71+
// I believe the problem is a race condition in the test container.
72+
// Adding sleeps is generally the worst possible way to "fix" such errors, but it may work in this case.
73+
std::this_thread::sleep_for(1s);
74+
7075
// Fetch again
7176
reply = RequestBuilder(ctx)
7277
.Get(GetDockerUrl(http_url) + "/" + post.id) // URL

tests/functional/ManyConnectionsTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ TEST(ManyConnections, CRUD) {
118118
// We can't just wait on the lock since we are in a co-routine.
119119
// So we use the async_wait() to poll in stead.
120120
while(!locker.try_lock()) {
121-
boost::asio::deadline_timer timer(rest_client->GetIoService(),
122-
boost::posix_time::milliseconds(1));
121+
boost::asio::steady_timer timer(rest_client->GetIoService(), 1ms);
123122
timer.async_wait(ctx.GetYield());
124123
}
125124
locker.unlock();

tests/functional/OwnIoserviceTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ TEST(OwnIoservice, All)
7575
// We can't just wait on the lock since we are in a co-routine.
7676
// So we use the async_wait() to poll in stead.
7777
while(!mutex.try_lock()) {
78-
boost::asio::deadline_timer timer(rest_client->GetIoService(),
79-
boost::posix_time::milliseconds(1));
78+
boost::asio::steady_timer timer(rest_client->GetIoService(), 1ms);
8079
timer.async_wait(ctx.GetYield());
8180
}
8281
mutex.unlock();

0 commit comments

Comments
 (0)