Merge branch 'master' of github.com:bytemaster/fc
This commit is contained in:
commit
a5a88a50c7
6 changed files with 24 additions and 14 deletions
|
|
@ -1,9 +1,14 @@
|
||||||
#ifndef _FC_ERROR_HPP_
|
#pragma once
|
||||||
#define _FC_ERROR_HPP_
|
|
||||||
#include <fc/string.hpp>
|
#include <fc/string.hpp>
|
||||||
|
|
||||||
namespace fc {
|
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 task_canceled: public std::exception{};
|
||||||
struct thread_quit: public std::exception{};
|
struct thread_quit: public std::exception{};
|
||||||
struct wait_any_error: public std::exception{};
|
struct wait_any_error: public std::exception{};
|
||||||
|
|
@ -29,4 +34,3 @@ namespace fc {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _FC_ERROR_HPP_
|
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,9 @@ namespace fc {
|
||||||
void reserve( size_t );
|
void reserve( size_t );
|
||||||
size_t size()const;
|
size_t size()const;
|
||||||
size_t find( char c, size_t pos = 0 )const;
|
size_t find( char c, size_t pos = 0 )const;
|
||||||
size_t rfind( char c, size_t pos = 0 )const;
|
size_t rfind( char c, size_t pos = npos )const;
|
||||||
size_t rfind( const fc::string& c, size_t pos = 0 )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 resize( size_t s );
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef _FC_THREAD_HPP_
|
#pragma once
|
||||||
#define _FC_THREAD_HPP_
|
|
||||||
#include <fc/task.hpp>
|
#include <fc/task.hpp>
|
||||||
#include <fc/vector.hpp>
|
#include <fc/vector.hpp>
|
||||||
#include <fc/string.hpp>
|
#include <fc/string.hpp>
|
||||||
|
|
@ -175,4 +174,3 @@ namespace fc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ namespace fc {
|
||||||
size_t string::size()const { return my->size(); }
|
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::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(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); }
|
size_t string::rfind(const fc::string& c, size_t p)const { return my->rfind(c,p); }
|
||||||
void string::clear() { my->clear(); }
|
void string::clear() { my->clear(); }
|
||||||
void string::resize( size_t s ) { my->resize(s); }
|
void string::resize( size_t s ) { my->resize(s); }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <fc/thread.hpp>
|
#include <fc/thread.hpp>
|
||||||
#include <fc/vector.hpp>
|
#include <fc/vector.hpp>
|
||||||
|
#include <fc/sstream.hpp>
|
||||||
#include "thread_d.hpp"
|
#include "thread_d.hpp"
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
@ -179,8 +180,13 @@ namespace fc {
|
||||||
if( p[i]->ready() ) return i;
|
if( p[i]->ready() ) return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( timeout < time_point::now() )
|
if( timeout < time_point::now() ) {
|
||||||
BOOST_THROW_EXCEPTION( future_wait_timeout() );
|
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 ) {
|
if( !my->current ) {
|
||||||
my->current = new fc::context(&fc::thread::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 ) {
|
void thread::wait_until( promise_base::ptr&& p, const time_point& timeout ) {
|
||||||
if( p->ready() ) return;
|
if( p->ready() ) return;
|
||||||
if( timeout < time_point::now() )
|
if( timeout < time_point::now() )
|
||||||
BOOST_THROW_EXCEPTION( future_wait_timeout() );
|
BOOST_THROW_EXCEPTION( future_wait_timeout( p->get_desc() ) );
|
||||||
|
|
||||||
if( !my->current ) {
|
if( !my->current ) {
|
||||||
my->current = new fc::context(&fc::thread::current());
|
my->current = new fc::context(&fc::thread::current());
|
||||||
|
|
|
||||||
4
vendor/CMakeLists.txt
vendored
4
vendor/CMakeLists.txt
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
add_subdirectory( libssh2-1.4.2 )
|
add_subdirectory( libssh2-1.4.2 )
|
||||||
add_subdirectory( zlib-1.2.7)
|
#add_subdirectory( zlib-1.2.7)
|
||||||
#add_subdirectory( sigar )
|
add_subdirectory( sigar )
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue