fixed thread::schedule

This commit is contained in:
Daniel Larimer 2012-09-22 21:26:13 -04:00
parent 7f68de063c
commit 0d5afe86d9
5 changed files with 17 additions and 5 deletions

View file

@ -55,9 +55,9 @@ namespace fc {
const fc::string& a1 );
void throw_exception_( const char* func, const char* file, int line, const char* msg,
const fc::string& a1, const fc::string& a2 );
void throw_exception( const char* func, const char* file, int line, const char* msg,
void throw_exception_( const char* func, const char* file, int line, const char* msg,
const fc::string& a1, const fc::string& a2, const fc::string& a3 );
void throw_exception( const char* func, const char* file, int line, const char* msg,
void throw_exception_( const char* func, const char* file, int line, const char* msg,
const fc::string& a1, const fc::string& a2, const fc::string& a3, const fc::string& a4 );
template<typename T>
@ -83,6 +83,10 @@ namespace fc {
void throw_exception( const char* func, const char* file, int line, const char* msg, T1&& a1, T2&& a2 ) {
throw_exception_( func, file, line, msg, to_string(fc::forward<T1>(a1) ), to_string( fc::forward<T2>(a2) ) );
}
template<typename T1, typename T2, typename T3>
void throw_exception( const char* func, const char* file, int line, const char* msg, T1&& a1, T2&& a2, T3&& a3 ) {
throw_exception_( func, file, line, msg, to_string(fc::forward<T1>(a1) ), to_string( fc::forward<T2>(a2) ), to_string( fc::forward<T3>(a3) ) );
}
} // namespace fc

View file

@ -49,6 +49,8 @@ namespace fc {
bool operator == ( const string& s )const;
bool operator != ( const string& s )const;
friend bool operator < ( const string& a, const string& b );
string& operator+=( const string& s );
string& operator+=( char c );

View file

@ -94,11 +94,11 @@ namespace fc {
const fc::string& a1, const fc::string& a2 ) {
::boost::exception_detail::throw_exception_(fc::generic_exception( (boost::format(msg) % a1.c_str() %a2.c_str()).str().c_str()),func, file, line );
}
void throw_exception( const char* func, const char* file, int line, const char* msg,
void throw_exception_( const char* func, const char* file, int line, const char* msg,
const fc::string& a1, const fc::string& a2, const fc::string& a3 ) {
::boost::exception_detail::throw_exception_(fc::generic_exception(msg),func, file, line );
}
void throw_exception( const char* func, const char* file, int line, const char* msg,
void throw_exception_( const char* func, const char* file, int line, const char* msg,
const fc::string& a1, const fc::string& a2, const fc::string& a3, const fc::string& a4 ) {
::boost::exception_detail::throw_exception_(fc::generic_exception(msg),func, file, line );
}

View file

@ -94,6 +94,9 @@ namespace fc {
return *this;
}
bool operator < ( const string& a, const string& b ) {
return reinterpret_cast<const std::string&>(a) < reinterpret_cast<const std::string&>(b);
}
string operator + ( const string& s, const string& c ) {
return string(s) += c;
}

View file

@ -211,7 +211,7 @@ namespace fc {
}
void thread::async_task( task_base* t, const priority& p, const char* desc ) {
async_task( t, p, time_point::max(), desc );
async_task( t, p, time_point::min(), desc );
}
void thread::poke() {
@ -220,6 +220,9 @@ namespace fc {
}
void thread::async_task( task_base* t, const priority& p, const time_point& tp, const char* desc ) {
t->_when = tp;
// slog( "when %lld", t->_when.time_since_epoch().count() );
// slog( "delay %lld", (tp - fc::time_point::now()).count() );
task_base* stale_head = my->task_in_queue.load(boost::memory_order_relaxed);
do { t->_next = stale_head;
}while( !my->task_in_queue.compare_exchange_weak( stale_head, t, boost::memory_order_release ) );