For each item from only the first of the given observables deliver from the new observable that is returned, on the specified scheduler.
More...
Go to the source code of this file.
|
template<class... AN> |
auto | rxcpp::operators::amb (AN &&... an) -> operator_factory< amb_tag, AN... > |
| For each item from only the first of the given observables deliver from the new observable that is returned, on the specified scheduler. More...
|
|
For each item from only the first of the given observables deliver from the new observable that is returned, on the specified scheduler.
There are 2 variants of the operator:
- The source observable emits nested observables, one of the nested observables is selected.
- The source observable and the arguments v0...vn are used to provide the observables to select from.
- Template Parameters
-
Coordination | the type of the scheduler (optional). |
Value0 | ... (optional). |
ValueN | types of source observables (optional). |
- Parameters
-
cn | the scheduler to synchronize sources from different contexts (optional). |
v0 | ... (optional). |
vn | source observables (optional). |
- Returns
- Observable that emits the same sequence as whichever of the source observables first emitted an item or sent a termination notification.
If scheduler is omitted, identity_current_thread is used.
- Sample Code
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
printf("[thread %s] Timer2 fired\n", get_pid().c_str());
return 2;
});
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
values.
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139731164010304] Start task
[thread 139731137566464] Timer3 fired
[thread 139731137566464] OnNext: 3
[thread 139731137566464] OnCompleted
[thread 139731164010304] Finish task
auto values = base.
amb();
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
auto values = o1.
amb(o2, o3);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
printf("[thread %s] Timer2 fired\n", get_pid().c_str());
return 2;
});
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
values.
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139731164010304] Start task
[thread 139731145959168] Timer3 fired
[thread 139731145959168] OnNext: 3
[thread 139731145959168] OnCompleted
[thread 139731164010304] Finish task
◆ RXCPP_OPERATORS_RX_AMB_HPP
#define RXCPP_OPERATORS_RX_AMB_HPP |