Skip to content

Commit

Permalink
default scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino committed Nov 30, 2022
1 parent a164951 commit 17c9a34
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/rpp/rpp/schedulers/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ using current_thread = trampoline;
class new_thread;
class run_loop;
} // namespace rpp::schedulers

namespace rpp::schedulers::default_schedulers
{
using iteration = trampoline;
} // namespace rpp::default_schedulers
8 changes: 5 additions & 3 deletions src/rpp/rpp/sources/from.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#pragma once

#include <rpp/memory_model.hpp>
#include <rpp/schedulers/immediate_scheduler.hpp>
#include <rpp/schedulers/trampoline_scheduler.hpp>
#include <rpp/sources/create.hpp>
#include <rpp/sources/fwd.hpp>
#include <rpp/utils/utilities.hpp>
Expand Down Expand Up @@ -183,6 +183,8 @@ auto just(const schedulers::constraint::scheduler auto& scheduler, T&& item, Ts&
* \param item first value to be sent
* \param items rest values to be sent
* \return rpp::specific_observable with provided item
*
* \warning In this case trampoline scheduler would be used.
*
* \par Examples:
* \snippet just.cpp just
Expand All @@ -208,7 +210,7 @@ auto just(T&& item, Ts&& ...items) requires (rpp::details::is_header_included<rp
*
* \tparam memory_model rpp::memory_model strategy used to handle provided iterable
* \param scheduler is scheduler used for scheduling of submissions: next item will be submitted to scheduler when previous one is executed
* \param iterable container with values which will be flattened
* \param iterable container with values which will be flattened. By default used trampoline scheduler
*
* \par Examples:
* \snippet from.cpp from_iterable
Expand All @@ -218,7 +220,7 @@ auto just(T&& item, Ts&& ...items) requires (rpp::details::is_header_included<rp
* \ingroup creational_operators
* \see https://reactivex.io/documentation/operators/from.html
*/
template<memory_model memory_model /* = memory_model::use_stack */, schedulers::constraint::scheduler TScheduler /* = schedulers::immediate */>
template<memory_model memory_model /* = memory_model::use_stack */, schedulers::constraint::scheduler TScheduler /* = rpp::schedulers::default_schedulers::iteration */>
auto from_iterable(constraint::iterable auto&& iterable, const TScheduler& scheduler /* = TScheduler{} */) requires rpp::details::is_header_included<rpp::details::from_tag, TScheduler >
{
using Container = std::decay_t<decltype(iterable)>;
Expand Down
6 changes: 3 additions & 3 deletions src/rpp/rpp/sources/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ auto just(const schedulers::constraint::scheduler auto& scheduler, T&& item, Ts&
template<memory_model memory_model = memory_model::use_stack, typename T, typename ...Ts>
auto just(T&& item, Ts&& ...items) requires (rpp::details::is_header_included<rpp::details::just_tag, T, Ts...> && (constraint::decayed_same_as<T, Ts> && ...));

template<memory_model memory_model= memory_model::use_stack, schedulers::constraint::scheduler TScheduler = schedulers::immediate>
template<memory_model memory_model= memory_model::use_stack, schedulers::constraint::scheduler TScheduler = rpp::schedulers::default_schedulers::iteration>
auto from_iterable(constraint::iterable auto&& iterable, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included <rpp::details::from_tag, TScheduler > ;

template<memory_model memory_model = memory_model::use_stack>
auto from_callable(std::invocable<> auto&& callable) requires rpp::details::is_header_included<rpp::details::from_tag, decltype(callable)>;

//************************ INTERVAL *********************//
template<schedulers::constraint::scheduler TScheduler = schedulers::immediate>
template<schedulers::constraint::scheduler TScheduler = rpp::schedulers::default_schedulers::iteration>
auto interval(schedulers::duration period, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>;

template<schedulers::constraint::scheduler TScheduler = schedulers::immediate>
template<schedulers::constraint::scheduler TScheduler = rpp::schedulers::default_schedulers::iteration>
auto interval(schedulers::duration first_delay, schedulers::duration period, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>;
} // namespace rpp::observable

Expand Down
10 changes: 5 additions & 5 deletions src/rpp/rpp/sources/interval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <rpp/sources/fwd.hpp>
#include <rpp/sources/create.hpp>
#include <rpp/schedulers/fwd.hpp>
#include <rpp/schedulers/immediate_scheduler.hpp>
#include <rpp/schedulers/trampoline_scheduler.hpp>

#include <type_traits>

Expand All @@ -33,7 +33,7 @@ namespace rpp::observable
* \warn First emission also scheduled and delayed with same interval
*
* \param period period which would be used to delay emissions between each other
* \param scheduler used for scheduling this periodic emissions
* \param scheduler used for scheduling this periodic emissions. By default used trampoline scheduler
* \return rpp::specific_observable which emits values with provided time_interval
*
* \par Examples:
Expand All @@ -42,7 +42,7 @@ namespace rpp::observable
* \ingroup creational_operators
* \see https://reactivex.io/documentation/operators/interval.html
*/
template<schedulers::constraint::scheduler TScheduler /*= schedulers::immediate*/>
template<schedulers::constraint::scheduler TScheduler /*= rpp::schedulers::default_schedulers::iteration*/>
auto interval(schedulers::duration period, const TScheduler& scheduler /* = TScheduler{} */) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>
{
return interval(period, period, scheduler);
Expand All @@ -58,7 +58,7 @@ namespace rpp::observable
*
* \param first_delay period which would be used to delay first emission
* \param period period which would be used to delay emissions between each other
* \param scheduler used for scheduling this periodic emissions
* \param scheduler used for scheduling this periodic emissions. By default used trampoline scheduler
* \return rpp::specific_observable which emits values with provided time_interval
*
* \par Examples:
Expand All @@ -67,7 +67,7 @@ namespace rpp::observable
* \ingroup creational_operators
* \see https://reactivex.io/documentation/operators/interval.html
*/
template<schedulers::constraint::scheduler TScheduler /*= schedulers::immediate*/>
template<schedulers::constraint::scheduler TScheduler /*= rpp::schedulers::default_schedulers::iteration*/>
auto interval(schedulers::duration first_delay, schedulers::duration period, const TScheduler& scheduler /* = TScheduler{} */) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>
{
return source::create<size_t>([first_delay, period, scheduler](auto&& subscriber)
Expand Down

1 comment on commit 17c9a34

@victimsnino
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.