Skip to content

Commit

Permalink
Slight performance tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
grantila committed Mar 12, 2017
1 parent 13ca098 commit fa55f68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 9 additions & 2 deletions libs/q/include/q/time_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,22 @@ class time_set
map_.emplace( std::move( time ), std::move( t ) );
}

bool exists_before_or_at(
timer::point_type time = timer::point_type::clock::now( ) )
bool exists_before_or_at( timer::point_type time )
{
if ( empty( ) )
return false;

return !( map_.begin( )->first > time );
}

bool exists_before_or_at( )
{
if ( empty( ) )
return false;

return exists_before_or_at( timer::point_type::clock::now( ) );
}

T pop( )
{
auto iter = map_.begin( );
Expand Down
12 changes: 4 additions & 8 deletions libs/q/src/blocking_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ void blocking_dispatcher::start( )
pimpl_->running_ = true;
pimpl_->started_ = true;

auto duration_max = timer::duration_type::max( );

do
{
if ( pimpl_->stop_asap_ )
Expand Down Expand Up @@ -114,6 +112,8 @@ void blocking_dispatcher::start( )
Q_AUTO_UNIQUE_UNLOCK( lock );

_task.task_( );

continue;
}

if ( pimpl_->running_ && !_task )
Expand All @@ -122,12 +122,8 @@ void blocking_dispatcher::start( )
{
auto next = pimpl_->timer_tasks_.next_time( );

if ( next != duration_max )
{
pimpl_->cond_.wait_for(
lock, next );
continue;
}
pimpl_->cond_.wait_for( lock, next );
continue;
}
pimpl_->cond_.wait( lock );
}
Expand Down

0 comments on commit fa55f68

Please sign in to comment.