This file is indexed.

/usr/include/caf/io/spawn_io.hpp is in libcaf-dev 0.13.2-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/******************************************************************************
 *                       ____    _    _____                                   *
 *                      / ___|  / \  |  ___|    C++                           *
 *                     | |     / _ \ | |_       Actor                         *
 *                     | |___ / ___ \|  _|      Framework                     *
 *                      \____/_/   \_|_|                                      *
 *                                                                            *
 * Copyright (C) 2011 - 2015                                                  *
 * Dominik Charousset <dominik.charousset (at) haw-hamburg.de>                *
 *                                                                            *
 * Distributed under the terms and conditions of the BSD 3-Clause License or  *
 * (at your option) under the terms and conditions of the Boost Software      *
 * License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE.       *
 *                                                                            *
 * If you did not receive a copy of the license files, see                    *
 * http://opensource.org/licenses/BSD-3-Clause and                            *
 * http://www.boost.org/LICENSE_1_0.txt.                                      *
 ******************************************************************************/

#ifndef CAF_IO_SPAWN_IO_HPP
#define CAF_IO_SPAWN_IO_HPP

#include <functional>

#include "caf/spawn.hpp"

#include "caf/io/broker.hpp"
#include "caf/io/middleman.hpp"
#include "caf/io/connection_handle.hpp"

#include "caf/io/network/native_socket.hpp"

namespace caf {
namespace io {

/**
 * Spawns a new functor-based broker.
 */
template <spawn_options Os = no_spawn_options,
     typename F = std::function<void(broker*)>, class... Ts>
actor spawn_io(F fun, Ts&&... xs) {
  return spawn<broker::functor_based>(std::move(fun), std::forward<Ts>(xs)...);
}

/**
 * Spawns a new functor-based broker connecting to `host:port.
 */
template <spawn_options Os = no_spawn_options,
      typename F = std::function<void(broker*)>, class... Ts>
actor spawn_io_client(F fun, const std::string& host,
                      uint16_t port, Ts&&... xs) {
  // provoke compiler error early
  using fun_res = decltype(fun(static_cast<broker*>(nullptr),
                               connection_handle{},
                               std::forward<Ts>(xs)...));
  // prevent warning about unused local type
  static_assert(std::is_same<fun_res, fun_res>::value,
                "your compiler is lying to you");
  // works around an issue with older GCC releases that could not handle
  // variadic template parameter packs inside lambdas by storing into a
  // std::function first (using `auto init =` won't compile on Clang)
  auto mfptr = &broker::functor_based::init<F, connection_handle, Ts...>;
  using bi = std::function<void (broker::functor_based*, F, connection_handle)>;
  using namespace std::placeholders;
  bi init = std::bind(mfptr, _1, _2, _3, std::forward<Ts>(xs)...);
  return spawn_class<broker::functor_based>(
        nullptr,
        [&](broker::functor_based* ptr) {
          auto mm = middleman::instance();
          auto hdl = mm->backend().add_tcp_scribe(ptr, host, port);
          init(ptr, fun, hdl);
        });
}

/**
 * Spawns a new broker as server running on given `port`.
 */
template <spawn_options Os = no_spawn_options,
          class F = std::function<void(broker*)>, class... Ts>
actor spawn_io_server(F fun, uint16_t port, Ts&&... xs) {
  // same workaround as above
  auto mfptr = &broker::functor_based::init<F, Ts...>;
  using bi = std::function<void (broker::functor_based*, F)>;
  using namespace std::placeholders;
  bi init = std::bind(mfptr, _1, _2, std::forward<Ts>(xs)...);
  return spawn_class<broker::functor_based>(
        nullptr,
        [&](broker::functor_based* ptr) {
          auto mm = middleman::instance();
          mm->backend().add_tcp_doorman(ptr, port);
          init(ptr, std::move(fun));
        });
}

} // namespace io
} // namespace caf

#endif // CAF_IO_SPAWN_IO_HPP