Compile boost and first version of coro thread pool
This commit is contained in:
parent
3472237c5d
commit
529fadbf96
|
@ -1,26 +1,48 @@
|
|||
find_package(Boost 1.72)
|
||||
find_package(Boost 1.72 EXACT COMPONENTS context QUIET)
|
||||
|
||||
if(Boost_FOUND)
|
||||
add_library(boost_target INTERFACE)
|
||||
target_link_libraries(boost_target INTERFACE Boost::boost)
|
||||
target_link_libraries(boost_target INTERFACE Boost::boost Boost::coroutine2)
|
||||
else()
|
||||
# Configure the boost toolset to use
|
||||
set(BOOTSTRAP_COMMAND "./bootstrap.sh --with-libraries=context")
|
||||
set(BOOST_COMPILER_FLAGS -fvisibility=hidden -fPIC -std=c++14 -w)
|
||||
if(APPLE)
|
||||
set(BOOST_TOOLSET "darwin")
|
||||
elseif(CLANG)
|
||||
set(BOOST_TOOLSET "clang")
|
||||
set(BOOTSTRAP_COMMAND "${BOOTSTRAP_COMMAND} --with-toolset=clang")
|
||||
else()
|
||||
set(BOOST_TOOLSET "gcc")
|
||||
endif()
|
||||
if(APPLE OR USE_LIBCXX)
|
||||
list(APPEND BOOST_COMPILER_FLAGS -stdlib=libc++)
|
||||
endif()
|
||||
set(BOOST_ADDITIONAL_COMPILE_OPTIOINS "")
|
||||
foreach(flag IN LISTS BOOST_COMPILER_FLAGS)
|
||||
string(APPEND BOOST_ADDITIONAL_COMPILE_OPTIOINS "<cxxflags>${flag} ")
|
||||
endforeach()
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/user-config.jam.cmake ${CMAKE_BINARY_DIR}/user-config.jam)
|
||||
|
||||
include(ExternalProject)
|
||||
set(BOOST_INSTALL_DIR "${CMAKE_BINARY_DIR}/boost_install")
|
||||
ExternalProject_add(boostProject
|
||||
URL "https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2"
|
||||
URL_HASH SHA256=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=context
|
||||
BUILD_COMMAND ./b2 link=static --prefix=${BOOST_INSTALL_DIR} --user-config=${CMAKE_BINARY_DIR}/user-config.jam install
|
||||
BUILD_IN_SOURCE ON
|
||||
INSTALL_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
BUILD_BYPRODUCTS <SOURCE_DIR>/boost/config.hpp)
|
||||
BUILD_BYPRODUCTS "${BOOST_INSTALL_DIR}/boost/config.hpp"
|
||||
"${BOOST_INSTALL_DIR}/lib/libboost_context.a")
|
||||
|
||||
ExternalProject_Get_property(boostProject SOURCE_DIR)
|
||||
|
||||
set(BOOST_INCLUDE_DIR ${SOURCE_DIR})
|
||||
message(STATUS "Boost include dir ${BOOST_INCLUDE_DIR}")
|
||||
add_library(boost_context STATIC IMPORTED)
|
||||
add_dependencies(boost_context boostProject)
|
||||
set_target_properties(boost_context PROPERTIES IMPORTED_LOCATION "${BOOST_INSTALL_DIR}/lib/libboost_context.a")
|
||||
|
||||
add_library(boost_target INTERFACE)
|
||||
add_dependencies(boost_target boostProject)
|
||||
target_include_directories(boost_target SYSTEM INTERFACE ${BOOST_INCLUDE_DIR})
|
||||
target_include_directories(boost_target SYSTEM INTERFACE ${BOOST_INSTALL_DIR}/include)
|
||||
target_link_libraries(boost_target INTERFACE boost_context)
|
||||
endif()
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
using @BOOST_TOOLSET@ : : @CMAKE_CXX_COMPILER@ : @BOOST_ADDITIONAL_COMPILE_OPTIOINS@ ;
|
||||
using python : @PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@ : @PYTHON_EXECUTABLE@ : @PYTHON_INCLUDE_DIRS@ ;
|
||||
|
|
|
@ -263,44 +263,18 @@ public:
|
|||
|
||||
typedef WorkPool<Coroutine, ThreadUnsafeSpinLock, true> CoroPool;
|
||||
|
||||
|
||||
|
||||
ACTOR void coroSwitcher( Future<Void> what, TaskPriority taskID, Coro* coro ) {
|
||||
try {
|
||||
// state double t = now();
|
||||
wait(what);
|
||||
//if (g_network->isSimulated() && g_simulator.getCurrentProcess()->rebooting && now()!=t)
|
||||
// TraceEvent("NonzeroWaitDuringReboot").detail("TaskID", taskID).detail("Elapsed", now()-t).backtrace("Flow");
|
||||
} catch (Error&) {}
|
||||
wait( delay(0, taskID) );
|
||||
Coro_switchTo_( swapCoro(coro), coro );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CoroThreadPool::waitFor( Future<Void> what ) {
|
||||
ASSERT (current_coro != main_coro);
|
||||
ASSERT(current_coro != nullptr);
|
||||
if (what.isReady()) return;
|
||||
// double t = now();
|
||||
coroSwitcher(what, g_network->getCurrentTask(), current_coro);
|
||||
Coro_switchTo_( swapCoro(main_coro), main_coro );
|
||||
//if (g_network->isSimulated() && g_simulator.getCurrentProcess()->rebooting && now()!=t)
|
||||
// TraceEvent("NonzeroWaitDuringReboot").detail("TaskID", currentTaskID).detail("Elapsed", now()-t).backtrace("Coro");
|
||||
ASSERT( what.isReady() );
|
||||
auto c = current_coro;
|
||||
current_coro = nullptr;
|
||||
c->send(what);
|
||||
}
|
||||
|
||||
// Right After INet2::run
|
||||
void CoroThreadPool::init()
|
||||
{
|
||||
if (!current_coro) {
|
||||
current_coro = main_coro = Coro_new();
|
||||
if (main_coro == nullptr)
|
||||
platform::outOfMemory();
|
||||
|
||||
Coro_initializeMainCoro(main_coro);
|
||||
//printf("Main thread: %d bytes stack presumed available\n", Coro_bytesLeftOnStack(current_coro));
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
Reference<IThreadPool> CoroThreadPool::createThreadPool() {
|
||||
|
|
Loading…
Reference in New Issue