some changes

This commit is contained in:
Naios 2015-08-09 12:29:11 +02:00
parent b24cc065b5
commit dac021d783
3 changed files with 52 additions and 20 deletions

View File

@ -32,4 +32,4 @@ install:
script:
- $CXX --version
- make -j 4
- ./continue_test
- ./ContinuableTest

View File

@ -11,7 +11,6 @@ if(MSVC)
"which doesn't support all required C++11 features. "
"(Visual Studio 2013 (Version >= 1800) is required!)")
message(STATUS "bad")
endif()
if(PLATFORM EQUAL 64)
@ -53,15 +52,15 @@ if(Boost_FOUND)
endif()
file(GLOB_RECURSE LIB_SOURCES include/*.cpp include/*.hpp include/*.h)
add_library(continue STATIC ${LIB_SOURCES})
add_library(Continuable STATIC ${LIB_SOURCES})
include_directories(include dep/concurrentqueue)
set(TEST_SOURCES test.cpp mockup.cpp)
add_executable(continue_test ${TEST_SOURCES})
add_executable(ContinuableTest ${TEST_SOURCES})
target_link_libraries(continue_test
continue
target_link_libraries(ContinuableTest
Continuable
${CMAKE_THREAD_LIBS_INIT}
)

View File

@ -81,30 +81,58 @@ Continuable<> mysql_query(std::string const& query)
});
}
void test_mockup()
/// This mockup shows how to create a continuable from a functional object.
void create_continuable_mockup()
{
/// Everything which accepts callbacks can be converted into a continuable.
/// Since nearly every async operation can be converted to use callbacks
{
Continuable<> continuable = make_continuable([]
Continuable</*std::string*/> continuable =
make_continuable([](std::function<void(std::string)>&& /*TODO Find out if its better to use call by value*/ callback)
{
return "hey";
callback("my result");
});
}
Continuable<> c1 = make_continuable([]
//
{
// Accept params from previous continuable...
Continuable<> continuable = make_continuable([](int param1, int param2)
{
// ... and return the next continuable
return mysql_query("some query content");
});
}
}
Continuable<> c2 = make_continuable([]
/// This mockup shows how to chain multiple continuables together
void chain_continuable_mockup()
{
// Best fitting functions
{
// Accept params from previous continuable...
Continuable<> continuable = make_continuable([](int param1, int param2)
{
// ... and return the next continuable
return mysql_query("some query content");
});
}
Continuable<> c3 = make_continuable([]
//
{
// Accept params from previous continuable...
Continuable<> continuable = make_continuable([](int param1, int param2)
{
// ... and return the next continuable
return mysql_query("some query content");
});
}
}
Continuable<> c4 = make_continuable([]
/// This mockup shows the basic usage and features of continuables waiting for 2 http requests and a database query.
void final_mockup()
{
});
Continuable<> c1, c2, c3, c4;
(std::move(c1) && std::move(c2))
.then(http_request("https://github.com/") &&
@ -118,6 +146,11 @@ void test_mockup()
.then([](bool hasContent, std::string google, ResultSet user)
{
});
// Continuable<> c11 = || std::move(c3);
}
void test_mockup()
{
create_continuable_mockup();
final_mockup();
}