RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
rx-sameworker.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 
3 #pragma once
4 
5 #if !defined(RXCPP_RX_SCHEDULER_SAME_WORKER_HPP)
6 #define RXCPP_RX_SCHEDULER_SAME_WORKER_HPP
7 
8 #include "../rx-includes.hpp"
9 
10 namespace rxcpp {
11 
12 namespace schedulers {
13 
15 {
16 private:
17  typedef same_worker this_type;
18  same_worker(const this_type&);
19 
20  rxsc::worker controller;
21 
22 public:
24  : controller(std::move(w))
25  {
26  }
27  virtual ~same_worker()
28  {
29  }
30 
31  virtual clock_type::time_point now() const {
32  return controller.now();
33  }
34 
36  // use different lifetime
37  auto inner_lifetime = controller.get_subscription();
38  auto token = inner_lifetime.add(cs);
39  cs.add([inner_lifetime, token](){inner_lifetime.remove(token);});
40  return worker(cs, controller);
41  }
42 };
43 
45  return make_scheduler<same_worker>(std::move(w));
46 }
47 
48 }
49 
50 }
51 
52 #endif
virtual ~same_worker()
Definition: rx-sameworker.hpp:27
Definition: rx-all.hpp:26
controls lifetime for scheduler::schedule and observable<T, SourceOperator>::subscribe.
Definition: rx-subscription.hpp:364
Definition: rx-sameworker.hpp:14
const composite_subscription & get_subscription() const
Definition: rx-scheduler.hpp:225
allows functions to be called at specified times and possibly in other contexts.
Definition: rx-scheduler.hpp:383
scheduler make_same_worker(rxsc::worker w)
Definition: rx-sameworker.hpp:44
clock_type::time_point now() const
return the current time for this worker
Definition: rx-scheduler.hpp:253
virtual worker create_worker(composite_subscription cs) const
Definition: rx-sameworker.hpp:35
same_worker(rxsc::worker w)
Definition: rx-sameworker.hpp:23
weak_subscription add(subscription s) const
Definition: rx-subscription.hpp:413
Definition: rx-scheduler.hpp:353
virtual clock_type::time_point now() const
Definition: rx-sameworker.hpp:31
Definition: rx-scheduler.hpp:200