Flow 1.0.2
Flow project: Full implementation reference.
node.cpp
Go to the documentation of this file.
1/* Flow
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19
23
25{
26
27// Implementations. For Node code pertaining to individual Server_sockets and Peer_sockets see their .cpp files.
28
29Node::Node(log::Logger* logger_ptr, util::Task_engine* target_async_task_engine,
30 const util::Udp_endpoint& low_lvl_endpoint,
31 Net_env_simulator* net_env_sim, Error_code* err_code,
32 const Node_options& opts) :
33 net_flow::Node(logger_ptr, low_lvl_endpoint, net_env_sim, err_code, opts),
34 m_target_task_engine(target_async_task_engine) // May be null.
35{
36 FLOW_LOG_INFO("Starting net_flow::asio::Node [" << static_cast<void*>(this) << "]; "
37 "saving target Task_engine [" << static_cast<void*>(target_async_task_engine) << "].");
38}
39
41{
42 // Not thread-safe against set_async_task_engine(). Discussed in my doc header.
44}
45
46void Node::set_async_task_engine(util::Task_engine* target_async_task_engine)
47{
48 // Not thread-safe against m_target_task_engine access. Discussed in my doc header.
49 FLOW_LOG_INFO("Object [" << this << "] has been assigned an Task_engine at [" << target_async_task_engine << "]; "
50 "currently [" << static_cast<void*>(m_target_task_engine) << "].");
51 m_target_task_engine = target_async_task_engine;
52}
53
54} // namespace flow::net_flow::asio
Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...
Definition: log.hpp:1291
Objects of this class can be fed to Node to make it internally simulate network conditions like loss,...
A subclass of net_flow::Node that adds the ability to easily and directly use net_flow sockets in gen...
Definition: node.hpp:236
void set_async_task_engine(util::Task_engine *target_async_task_engine)
Overwrites the value to be returned by next async_task_engine().
Definition: node.cpp:46
util::Task_engine * m_target_task_engine
See async_task_engine().
Definition: node.hpp:575
util::Task_engine * async_task_engine()
Pointer (possibly null) for the flow::util::Task_engine used by any coming async I/O calls and inheri...
Definition: node.cpp:40
Node(log::Logger *logger, util::Task_engine *target_async_task_engine, const util::Udp_endpoint &low_lvl_endpoint, Net_env_simulator *net_env_sim=0, Error_code *err_code=0, const Node_options &opts=Node_options())
Constructs Node.
Definition: node.cpp:29
#define FLOW_LOG_INFO(ARG_stream_fragment)
Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
Definition: log.hpp:197
Contains classes that add boost.asio integration to the main Flow-protocol classes such as net_flow::...
Definition: node.cpp:25
boost::asio::io_service Task_engine
Short-hand for boost.asio event service, the central class of boost.asio.
Definition: util_fwd.hpp:135
boost::asio::ip::udp::endpoint Udp_endpoint
Short-hand for the UDP endpoint (IP/port) type.
Definition: util_fwd.hpp:208
boost::system::error_code Error_code
Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...
Definition: common.hpp:503
A set of low-level options affecting a single Flow Node, including Peer_socket objects and other obje...
Definition: options.hpp:449