Skip to content

Commit

Permalink
GH-985 Remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 1, 2024
1 parent 8012d03 commit bb4d159
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
14 changes: 1 addition & 13 deletions libraries/chain/platform_timer_asio_fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,12 @@ void platform_timer::start(fc::time_point tp) {
if(x.count() <= 0)
expired = true;
else {
#if 0
std::promise<void> p;
auto f = p.get_future();
checktime_ios->post([&p,this]() {
expired = false;
p.set_value();
});
f.get();
#endif
expired = false;
my->timer->expires_after(std::chrono::microseconds(x.count()));
my->timer->async_wait([this](const boost::system::error_code& ec) {
if(ec)
return;
bool expected = false;
if (expired.compare_exchange_strong(expected, true)) {
call_expiration_callback();
}
expire_now();
});
}
}
Expand Down
5 changes: 1 addition & 4 deletions libraries/chain/platform_timer_kqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ platform_timer::platform_timer() {

if(c == 1 && anEvent.filter == EVFILT_TIMER) {
platform_timer* self = (platform_timer*)anEvent.udata;
bool expected = false;
if (self->expired.compare_exchange_strong(expected, true)) {
self->call_expiration_callback();
}
self->expire_now();
}
else if(c == 1 && anEvent.filter == EVFILT_USER)
return;
Expand Down
5 changes: 1 addition & 4 deletions libraries/chain/platform_timer_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ struct platform_timer::impl {

static void sig_handler(int, siginfo_t* si, void*) {
platform_timer* self = (platform_timer*)si->si_value.sival_ptr;
bool expected = false;
if (self->expired.compare_exchange_strong(expected, true)) {
self->call_expiration_callback();
}
self->expire_now();
}
};

Expand Down

0 comments on commit bb4d159

Please sign in to comment.