From 63c0440a809c0b22c4ddbd92627581919252b6f8 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 31 Dec 2012 11:06:10 -0500 Subject: [PATCH] fix fc::string::rfind default args --- include/fc/error.hpp | 12 ++++++++---- include/fc/string.hpp | 5 +++-- include/fc/thread.hpp | 4 +--- src/string.cpp | 1 + src/thread.cpp | 12 +++++++++--- vendor/CMakeLists.txt | 4 ++-- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/fc/error.hpp b/include/fc/error.hpp index cd6b939..b08087b 100644 --- a/include/fc/error.hpp +++ b/include/fc/error.hpp @@ -1,9 +1,14 @@ -#ifndef _FC_ERROR_HPP_ -#define _FC_ERROR_HPP_ +#pragma once #include namespace fc { - struct future_wait_timeout: public std::exception{}; + struct future_wait_timeout: public std::exception{ + future_wait_timeout( const fc::string& msg = "" ):m_msg(msg){} + ~future_wait_timeout()throw() {} + const char* what()const throw() { return m_msg.c_str(); } + private: + fc::string m_msg; + }; struct task_canceled: public std::exception{}; struct thread_quit: public std::exception{}; struct wait_any_error: public std::exception{}; @@ -29,4 +34,3 @@ namespace fc { }; } -#endif // _FC_ERROR_HPP_ diff --git a/include/fc/string.hpp b/include/fc/string.hpp index 945e803..490941e 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -65,8 +65,9 @@ namespace fc { void reserve( size_t ); size_t size()const; size_t find( char c, size_t pos = 0 )const; - size_t rfind( char c, size_t pos = 0 )const; - size_t rfind( const fc::string& c, size_t pos = 0 )const; + size_t rfind( char c, size_t pos = npos )const; + size_t rfind( const char* c, size_t pos = npos )const; + size_t rfind( const fc::string& c, size_t pos = npos )const; void resize( size_t s ); void clear(); diff --git a/include/fc/thread.hpp b/include/fc/thread.hpp index 4ebaf1a..37a5b21 100644 --- a/include/fc/thread.hpp +++ b/include/fc/thread.hpp @@ -1,5 +1,4 @@ -#ifndef _FC_THREAD_HPP_ -#define _FC_THREAD_HPP_ +#pragma once #include #include #include @@ -175,4 +174,3 @@ namespace fc { } } -#endif diff --git a/src/string.cpp b/src/string.cpp index 0420b96..0f164f8 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -34,6 +34,7 @@ namespace fc { size_t string::size()const { return my->size(); } size_t string::find(char c, size_t p)const { return my->find(c,p); } size_t string::rfind(char c, size_t p)const { return my->rfind(c,p); } + size_t string::rfind(const char* c, size_t p)const { return my->rfind(c,p); } size_t string::rfind(const fc::string& c, size_t p)const { return my->rfind(c,p); } void string::clear() { my->clear(); } void string::resize( size_t s ) { my->resize(s); } diff --git a/src/thread.cpp b/src/thread.cpp index fa73079..4aec978 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "thread_d.hpp" namespace fc { @@ -179,8 +180,13 @@ namespace fc { if( p[i]->ready() ) return i; } - if( timeout < time_point::now() ) - BOOST_THROW_EXCEPTION( future_wait_timeout() ); + if( timeout < time_point::now() ) { + fc::stringstream ss; + for( auto i = p.begin(); i != p.end(); ++i ) { + ss << (*i)->get_desc() <<", "; + } + BOOST_THROW_EXCEPTION( future_wait_timeout( ss.str() ) ); + } if( !my->current ) { my->current = new fc::context(&fc::thread::current()); @@ -264,7 +270,7 @@ namespace fc { void thread::wait_until( promise_base::ptr&& p, const time_point& timeout ) { if( p->ready() ) return; if( timeout < time_point::now() ) - BOOST_THROW_EXCEPTION( future_wait_timeout() ); + BOOST_THROW_EXCEPTION( future_wait_timeout( p->get_desc() ) ); if( !my->current ) { my->current = new fc::context(&fc::thread::current()); diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 7b4140e..b12310e 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory( libssh2-1.4.2 ) -add_subdirectory( zlib-1.2.7) -#add_subdirectory( sigar ) +#add_subdirectory( zlib-1.2.7) +add_subdirectory( sigar )