Ignore:
Timestamp:
05/16/09 20:58:17 (10 years ago)
Author:
Eoin
Message:

Auto exit after a (currently hardcoded) time working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/halSession.cpp

    r759 r760  
    3535        bittorrent_ini_(L"BitTorrent.xml"), 
    3636        the_torrents_(bittorrent_ini_), 
     37        action_timer_(io_service_), 
    3738        default_torrent_max_connections_(-1), 
    3839        default_torrent_max_uploads_(-1), 
     
    372373} 
    373374 
     375void bit_impl::execute_action(const boost::system::error_code& e, bit::timeout_actions action) 
     376{ 
     377        if (e != boost::asio::error::operation_aborted) 
     378        { 
     379                HAL_DEV_MSG(hal::wform(L"Doing action %1%") % action); 
     380 
     381                switch(action) 
     382                { 
     383                case bit::action_pause: 
     384                        session_->pause(); 
     385                        break; 
     386                case bit::action_resume: 
     387                        session_->resume(); 
     388                        break; 
     389                default: 
     390                        break; 
     391                }; 
     392        } 
     393        else 
     394        { 
     395                HAL_DEV_MSG(hal::wform(L"Action %1% aborted") % action); 
     396        } 
     397} 
     398 
     399void bit_impl::execute_callback(const boost::system::error_code& e, action_callback_t action) 
     400{ 
     401        if (e != boost::asio::error::operation_aborted) 
     402        { 
     403                HAL_DEV_MSG(L"Doing callback"); 
     404 
     405                action(); 
     406        } 
     407        else 
     408        { 
     409                HAL_DEV_MSG(L"Callback aborted"); 
     410        } 
     411} 
     412 
     413void bit_impl::schedual_action(boost::posix_time::ptime time, bit::timeout_actions action) 
     414{ 
     415        HAL_DEV_MSG(hal::wform(L"Schedual absolute action %1% at %2%") % action % time); 
     416 
     417        action_timer_.cancel(); 
     418 
     419        action_timer_.expires_at(time); 
     420        action_timer_.async_wait(bind(&bit_impl::execute_action, this, _1, action)); 
     421} 
     422void bit_impl::schedual_action(boost::posix_time::time_duration duration, bit::timeout_actions action) 
     423{ 
     424        HAL_DEV_MSG(hal::wform(L"Schedual relative action %1% in %2%") % action % duration); 
     425 
     426        action_timer_.cancel(); 
     427 
     428        action_timer_.expires_from_now(duration); 
     429        action_timer_.async_wait(bind(&bit_impl::execute_action, this, _1, action)); 
     430} 
     431 
     432void bit_impl::schedual_callback(boost::posix_time::ptime time, action_callback_t action) 
     433{ 
     434        HAL_DEV_MSG(hal::wform(L"Schedual absolute callback %1%") % time); 
     435 
     436        action_timer_.cancel(); 
     437 
     438        action_timer_.expires_at(time); 
     439        action_timer_.async_wait(bind(&bit_impl::execute_callback, this, _1, action)); 
     440} 
     441void bit_impl::schedual_callback(boost::posix_time::time_duration duration, action_callback_t action) 
     442{ 
     443        HAL_DEV_MSG(hal::wform(L"Schedual relative callback %1%") % duration); 
     444 
     445        action_timer_.cancel(); 
     446 
     447        action_timer_.expires_from_now(duration); 
     448        action_timer_.async_wait(bind(&bit_impl::execute_callback, this, _1, action)); 
     449}        
     450 
    374451void bit_impl::start_alert_handler() 
    375452{ 
Note: See TracChangeset for help on using the changeset viewer.