empty.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. /*
  3. * Copyright 2018-present Facebook, Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #include <folly/experimental/pushmi/detail/functional.h>
  18. #include <folly/experimental/pushmi/o/extension_operators.h>
  19. #include <folly/experimental/pushmi/o/submit.h>
  20. namespace pushmi {
  21. namespace detail {
  22. struct single_empty_sender_base : single_sender<ignoreSF, inlineEXF> {
  23. using properties = property_set<
  24. is_sender<>,
  25. is_single<>,
  26. is_always_blocking<>,
  27. is_fifo_sequence<>>;
  28. };
  29. template <class... VN>
  30. struct single_empty_impl {
  31. PUSHMI_TEMPLATE(class Out)
  32. (requires ReceiveValue<Out, VN...>)
  33. void operator()(
  34. single_empty_sender_base&,
  35. Out out) {
  36. ::pushmi::set_done(out);
  37. }
  38. };
  39. } // namespace detail
  40. namespace operators {
  41. template <class... VN>
  42. auto empty() {
  43. return make_single_sender(
  44. detail::single_empty_sender_base{}, detail::single_empty_impl<VN...>{});
  45. }
  46. inline auto empty() {
  47. return make_single_sender(
  48. detail::single_empty_sender_base{}, detail::single_empty_impl<>{});
  49. }
  50. } // namespace operators
  51. } // namespace pushmi