Skip to content

Commit

Permalink
Adapted example programs to the new promise class template
Browse files Browse the repository at this point in the history
  • Loading branch information
grantila committed Dec 28, 2016
1 parent 72c3bd3 commit 2ca23a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions libs/p/include/p/process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class process
: public std::enable_shared_from_this< process >
, public q::async_termination<
q::arguments< >,
std::tuple< int >
int
>
{
public:
template< typename Fn >
typename std::enable_if<
false,
::q::promise< Q_RESULT_OF_AS_ARGUMENT_TYPE( Fn )::tuple_type >
::q::detail::suitable_promise_t< Q_RESULT_OF_AS_ARGUMENT_TYPE( Fn )::tuple_type >
>::type
run( Fn&& fn )
{
Expand Down
10 changes: 5 additions & 5 deletions libs/q/include/q/promise/promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class generic_promise
* * then( tuple< T... > ) -> X... => generic_promise< X... >
*
* * fail( E ) -> void // Can not be continued (except for done())
* * fail( E ) -> generic_promise< tuple< T... > >
* * fail( E ) -> generic_promise< T... >
* // Can be continued, suitable for "retry" flow
*
* * done( ) -> void
Expand Down Expand Up @@ -616,7 +616,7 @@ class generic_promise
* or the exception immediately ("synchronously").
*
* Technically:
* promise< tuple< T... > > -> promise< expect< tuple< T... > > >
* promise< T... > -> promise< expect< tuple< T... > > >
*
* This is useful e.g. to collect a set of promises where some might
* have been resolved and some rejected. The reflected value, i.e. the
Expand All @@ -633,10 +633,10 @@ class generic_promise
*
* Technically:
*
* For a promise< tuple< > > or promise< tuple< T > >:
* promise< tuple< T/nothing > > -> promise< expect< T/nothing > >
* For a promise< > or promise< T >:
* promise< T/nothing > -> promise< expect< T/nothing > >
*
* For a promise< tuple< T1, T2... > >:
* For a promise< T1, T2... >:
* Same as reflect_tuple( )
*/
template< bool Simplified = sizeof...( Args ) < 2 >
Expand Down
6 changes: 3 additions & 3 deletions progs/benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ void benchmark_q_function( std::size_t iterations, std::string impl )
template< typename Start, typename Stop >
void benchmark_queueing_and_scheduling( Start&& start, Stop&& stop, bool parallel, q::queue_ptr queue, std::size_t iterations )
{
q::shared_promise< std::tuple< int > > promise = q::with( queue, 0 ).share( );
std::vector< q::promise< std::tuple< int > > > waitable;
q::promise< std::tuple< int > > serial_promise = q::with( queue, 0 );
q::shared_promise< int > promise = q::with( queue, 0 ).share( );
std::vector< q::promise< int > > waitable;
q::promise< int > serial_promise = q::with( queue, 0 );
waitable.reserve( iterations );

q::timer::duration_type total_dur( 0 );
Expand Down
12 changes: 6 additions & 6 deletions progs/playground/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ int main( int argc, char** argv )
{
e_f( );
} )
.fail( [ queue ]( std::exception_ptr e ) -> q::promise< std::tuple< > >
.fail( [ queue ]( std::exception_ptr e ) -> q::promise< >
{
try
{
Expand All @@ -265,7 +265,7 @@ int main( int argc, char** argv )
std::cerr << "are promise: " << q::are_promises< decltype( error_stuff2 ) >::value << std::endl;
std::cerr << "are promises: " << q::are_promises< decltype( error_stuff2 ), decltype( thread_stuff ) >::value << std::endl;
std::cerr << "are promises: " << q::are_promises< decltype( error_stuff2 ), std::true_type >::value << std::endl;
std::cerr << "are promises2: " << q::are_promises< q::promise< std::tuple< > >, q::promise< std::tuple< > > >::value << std::endl;
std::cerr << "are promises2: " << q::are_promises< q::promise< >, q::promise< > >::value << std::endl;

q::all( std::move( error_stuff2 ), std::move( thread_stuff ) )
.then( [ bd ]( )
Expand Down Expand Up @@ -312,7 +312,7 @@ int main( int argc, char** argv )
typedef std::tuple< std::tuple< std::string > > my_type;
bool are_same = Q_ARGUMENTS_ARE( fn_type, my_type )::value;

bool is_arg_same = ::q::is_argument_same_or_convertible<
bool is_arg_same = ::q::is_argument_same_or_convertible_t<
Q_ARGUMENTS_OF( fn_type ),
::q::arguments< my_type >
>::value;
Expand All @@ -329,10 +329,10 @@ int main( int argc, char** argv )
std::cout << "then got \"" << msg << "\", .stopping..." << std::endl;
};

typedef std::tuple< std::string > type_from;
typedef Q_ARGUMENTS_OF( decltype( string_to_void ) ) type_to;
typedef std::tuple< std::string > type_from;
typedef q::arguments_of_t< decltype( string_to_void ) > type_to;

auto is_conv = ::q::tuple_arguments< type_from >::is_convertible_to< type_to >::value;
auto is_conv = ::q::tuple_arguments_t< type_from >::template is_convertible_to< type_to >::value;
std::cout << "::::: " << is_conv << std::endl;


Expand Down

0 comments on commit 2ca23a4

Please sign in to comment.