Merge branch 'phoenix' of github.com:InvictusInnovations/fc into phoenix
This commit is contained in:
commit
4ed7659b2b
7 changed files with 64 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -42,3 +42,4 @@ libfc_debug.a
|
||||||
|
|
||||||
fc_automoc.cpp
|
fc_automoc.cpp
|
||||||
*.swp
|
*.swp
|
||||||
|
GitSHA3.cpp
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,6 @@ ELSE(WIN32)
|
||||||
|
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
|
||||||
|
|
||||||
include_directories( ${Boost_INCLUDE_DIR} )
|
|
||||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/vendor/salsa20 )
|
|
||||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include )
|
|
||||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/vendor/easylzma/src )
|
|
||||||
IF(NOT APPLE ) # then unix
|
IF(NOT APPLE ) # then unix
|
||||||
# Unix build:
|
# Unix build:
|
||||||
SET(SALSA_SRC vendor/salsa20/salsa20.s)
|
SET(SALSA_SRC vendor/salsa20/salsa20.s)
|
||||||
|
|
@ -174,8 +170,8 @@ IF(WIN32)
|
||||||
# Needed to disable MSVC autolinking feature (#pragma comment)
|
# Needed to disable MSVC autolinking feature (#pragma comment)
|
||||||
BOOST_ALL_NO_LIB
|
BOOST_ALL_NO_LIB
|
||||||
)
|
)
|
||||||
# Activate C++ exception handling inc. SEH to catch GPFs
|
# Activate C++ exception handling, assume extern C calls don't throw
|
||||||
target_compile_options(fc PUBLIC /EHa)
|
target_compile_options(fc PUBLIC /EHsc)
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall" )
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall" )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ namespace fc {
|
||||||
void* _functor;
|
void* _functor;
|
||||||
void (*_destroy_functor)(void*);
|
void (*_destroy_functor)(void*);
|
||||||
void (*_run_functor)(void*, void* );
|
void (*_run_functor)(void*, void* );
|
||||||
|
|
||||||
|
void run_impl();
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
|
||||||
|
|
@ -175,5 +175,29 @@ namespace fc {
|
||||||
auto async( Functor&& f, const char* desc ="", priority prio = priority()) -> fc::future<decltype(f())> {
|
auto async( Functor&& f, const char* desc ="", priority prio = priority()) -> fc::future<decltype(f())> {
|
||||||
return fc::thread::current().async( fc::forward<Functor>(f), desc, prio );
|
return fc::thread::current().async( fc::forward<Functor>(f), desc, prio );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // end namespace fc
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
struct _EXCEPTION_POINTERS;
|
||||||
|
|
||||||
|
namespace fc {
|
||||||
|
/* There's something about the setup of the stacks created for fc::async tasks
|
||||||
|
* that screws up the global structured exception filters installed by
|
||||||
|
* SetUnhandledExceptionFilter(). The only way I've found to catch an
|
||||||
|
* unhaldned structured exception thrown in an async task is to put a
|
||||||
|
* __try/__except block inside the async task.
|
||||||
|
* We do just that, and if a SEH escapes outside the function running
|
||||||
|
* in the async task, fc will call an exception filter privided by
|
||||||
|
* set_unhandled_structured_exception_filter(), passing as arguments
|
||||||
|
* the result of GetExceptionCode() and GetExceptionInformation().
|
||||||
|
*
|
||||||
|
* Right now there is only one global exception filter, used for any
|
||||||
|
* async task.
|
||||||
|
*/
|
||||||
|
typedef int (*unhandled_exception_filter_type)(unsigned, _EXCEPTION_POINTERS*);
|
||||||
|
void set_unhandled_structured_exception_filter(unhandled_exception_filter_type new_filter);
|
||||||
|
unhandled_exception_filter_type get_unhandled_structured_exception_filter();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,11 @@
|
||||||
#include <fc/log/logger.hpp>
|
#include <fc/log/logger.hpp>
|
||||||
#include <boost/exception/all.hpp>
|
#include <boost/exception/all.hpp>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <fc/thread/thread.hpp>
|
||||||
|
# include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
task_base::task_base(void* func)
|
task_base::task_base(void* func)
|
||||||
:
|
:
|
||||||
|
|
@ -18,6 +23,17 @@ namespace fc {
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_base::run() {
|
void task_base::run() {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__try {
|
||||||
|
#endif
|
||||||
|
run_impl();
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
} __except (get_unhandled_structured_exception_filter() ? get_unhandled_structured_exception_filter()(GetExceptionCode(), GetExceptionInformation()) : EXCEPTION_CONTINUE_SEARCH) {
|
||||||
|
ExitProcess(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void task_base::run_impl() {
|
||||||
try {
|
try {
|
||||||
_run_functor( _functor, _promise_impl );
|
_run_functor( _functor, _promise_impl );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -381,5 +381,19 @@ namespace fc {
|
||||||
return this == ¤t();
|
return this == ¤t();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
}
|
/* support for providing a structured exception handler for async tasks */
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
unhandled_exception_filter_type unhandled_structured_exception_filter = nullptr;
|
||||||
|
}
|
||||||
|
void set_unhandled_structured_exception_filter(unhandled_exception_filter_type new_filter)
|
||||||
|
{
|
||||||
|
detail::unhandled_structured_exception_filter = new_filter;
|
||||||
|
}
|
||||||
|
unhandled_exception_filter_type get_unhandled_structured_exception_filter()
|
||||||
|
{
|
||||||
|
return detail::unhandled_structured_exception_filter;
|
||||||
|
}
|
||||||
|
#endif // _MSC_VER
|
||||||
|
} // end namespace fc
|
||||||
|
|
|
||||||
|
|
@ -430,9 +430,9 @@ namespace fc {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//ilog( "..." );
|
//ilog( "..." );
|
||||||
FC_ASSERT( c != current )
|
|
||||||
//ilog( "ready_push_front" );
|
//ilog( "ready_push_front" );
|
||||||
ready_push_front( c );
|
if (c != current)
|
||||||
|
ready_push_front( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return time_point::min();
|
return time_point::min();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue