22#include <boost/asio.hpp>
23#include <boost/thread.hpp>
24#include <boost/thread/null_mutex.hpp>
25#include <boost/core/span.hpp>
52template<
typename Key,
typename Mapped,
typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>>
54template<
typename Key,
typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>>
60template<
typename range_t>
62template<
typename range_t>
65template<
typename Value>
68template<
typename Target_ptr,
69 typename Const_target_ptr
70 =
typename std::pointer_traits<Target_ptr>::template rebind<typename Target_ptr::element_type const>>
75template<
typename Thread_local_state_t>
78template<
typename Shared_state_t>
99namespace this_thread = boost::this_thread;
214using Timer = boost::asio::basic_waitable_timer<Fine_clock>;
276template<
typename Mutex>
286template<
typename Shared_mutex>
352template<
typename T,
size_t E = DYNAMIC_EXTENT>
366template<
typename Key_t,
typename Mapped_t,
typename Hash_t,
typename Pred_t>
379template<
typename Key_t,
typename Hash_t,
typename Pred_t>
509template<
typename Const_buffer_sequence>
510std::ostream&
buffers_to_ostream(std::ostream& os,
const Const_buffer_sequence& data,
const std::string& indentation,
511 size_t bytes_per_line = 0);
528template<
typename Const_buffer_sequence>
529std::string
buffers_dump_string(
const Const_buffer_sequence& data,
const std::string& indentation,
530 size_t bytes_per_line = 0);
581template<
typename Time_unit,
typename N_items>
582double to_mbit_per_sec(N_items items_per_time,
size_t bits_per_item = 8);
601template<
typename Integer,
typename Integer2>
602constexpr Integer
ceil_div(Integer dividend, Integer2 divisor);
622template<
typename Integer,
typename Integer2>
647template<
typename Cleanup_func>
665bool in_closed_range(T
const & min_val, T
const & val, T
const & max_val);
734template<
typename Container>
735bool key_exists(
const Container& container,
const typename Container::key_type& key);
763template<
typename Minuend,
typename Subtrahend>
764bool subtract_with_floor(Minuend* minuend,
const Subtrahend& subtrahend,
const Minuend& floor = 0);
786template<
typename From,
typename To>
808template<
typename Map,
typename Sequence>
830template<
typename Map,
typename Sequence>
832 (Sequence
const & src_seq, Map* target_map,
833 const Function<
typename Map::mapped_type (
size_t)>& idx_to_map_val_func);
860template<
typename... T>
877template<
typename... T>
890template<
typename... T>
943template<
typename Enum>
944Enum
istream_to_enum(std::istream* is_ptr, Enum enum_default, Enum enum_sentinel,
945 bool accept_num_encoding =
true,
bool case_sensitive =
false,
946 Enum enum_lowest = Enum(0));
984template<
typename Thread_local_state_t>
1001#define FLOW_UTIL_WHERE_AM_I() \
1002 FLOW_UTIL_WHERE_AM_I_FROM_ARGS(::flow::util::get_last_path_segment \
1003 (::flow::util::String_view(__FILE__, sizeof(__FILE__) - 1)), \
1004 ::flow::util::String_view(__FUNCTION__, sizeof(__FUNCTION__) - 1), \
1021#define FLOW_UTIL_WHERE_AM_I_STR() \
1022 ::flow::util::get_where_am_i_str(::flow::util::get_last_path_segment \
1023 (::flow::util::String_view(__FILE__, sizeof(__FILE__) - 1)), \
1024 ::flow::util::String_view(__FUNCTION__, sizeof(__FUNCTION__) - 1), \
1129#define FLOW_UTIL_SEMICOLON_SAFE(ARG_func_macro_definition) \
1132 ARG_func_macro_definition \
An object of this class is a map that combines the lookup speed of an unordered_map<> and ordering an...
An object of this class is a map that combines the lookup speed of an unordered_set<> and ordering an...
An empty interface, consisting of nothing but a default virtual destructor, intended as a boiler-plat...
Optional-use companion to Thread_local_state_registry that enables the Polled_share_state pattern whe...
A simple RAII-pattern class template that, at construction, sets the specified location in memory to ...
Convenience class template that endows the given subclass T with nested aliases Ptr and Const_ptr ali...
Similar to ostringstream but allows fast read-only access directly into the std::string being written...
Similar to boost::thread_specific_ptr<T> but with built-in lazy-init semantics; and more importantly ...
Each object of this class stores (at construction) and returns (on demand) a numeric ID unique from a...
Flow module containing miscellaneous general-use facilities that don't fit into any other Flow module...
boost::unique_lock< Mutex_recursive > Lock_guard_recursive
(Deprecated given C++1x) Short-hand for advanced-capability RAII lock guard for Mutex_recursive mutex...
bool in_closed_open_range(T const &min_val, T const &val, T const &max_val)
Returns true if and only if the given value is within the given range, given as a [low,...
bool key_exists(const Container &container, const typename Container::key_type &key)
Returns true if and only if the given key is present at least once in the given associative container...
void beautify_chrono_ostream(std::ostream *os_ptr)
Sets certain chrono-related formatting on the given ostream that results in a consistent,...
Auto_cleanup setup_auto_cleanup(const Cleanup_func &func)
Provides a way to execute arbitrary (cleanup) code at the exit of the current block.
Thread::id Thread_id
Short-hand for an OS-provided ID of a util::Thread.
void sequence_to_inverted_lookup_map(Sequence const &src_seq, Map *target_map, const Function< typename Map::mapped_type(size_t)> &idx_to_map_val_func)
Similar to the 2-arg overload of sequence_to_inverted_lookup_map() but with the ability to store a va...
double to_mbit_per_sec(N_items items_per_time, size_t bits_per_item)
Utility that converts a bandwidth in arbitrary units in both numerator and denominator to the same ba...
std::string buffers_dump_string(const Const_buffer_sequence &data, const std::string &indentation, size_t bytes_per_line)
Identical to buffers_to_ostream() but returns an std::string instead of writing to a given ostream.
Enum istream_to_enum(std::istream *is_ptr, Enum enum_default, Enum enum_sentinel, bool accept_num_encoding, bool case_sensitive, Enum enum_lowest)
Deserializes an enum class value from a standard input stream.
boost::span< T, E > Span
Short-hand for std::span-like type; that is contiguous sequence of objects with the first element of ...
void feed_args_to_ostream(std::ostream *os, T &&... ostream_args)
Function template that simply outputs arguments 2+ via << to the given ostream, in the order given.
std::ostream & operator<<(std::ostream &os, const Thread_local_state_registry< Thread_local_state_t > &val)
Serializes a Thread_local_state_registry to a standard output stream.
boost::asio::ip::address_v6 Ip_address_v6
Short-hand for the IPv6 address type.
boost::asio::ip::address_v4 Ip_address_v4
Short-hand for the IPv4 address type.
bool subtract_with_floor(Minuend *minuend, const Subtrahend &subtrahend, const Minuend &floor)
Performs *minuend -= subtrahend, subject to a floor of floor.
size_t deep_size(const std::string &val)
Estimate of memory footprint of the given value, including memory allocated on its behalf – but exclu...
constexpr Integer round_to_multiple(Integer dividend, Integer2 unit)
Returns the smallest integer >= the given integer dividend such that it is a multiple of the given in...
boost::unique_lock< Mutex > Lock_guard
Short-hand for advanced-capability RAII lock guard for any mutex, ensuring exclusive ownership of tha...
boost::shared_mutex Mutex_shared_non_recursive
Short-hand for non-reentrant, shared-or-exclusive mutex.
size_t size_unit_convert(From num_froms)
Answers the question what's the smallest integer number of Tos sufficient to verbatim store the given...
boost::shared_lock< Mutex_shared_non_recursive > Lock_guard_shared_non_recursive_sh
(Deprecated given C++1x) Short-hand for shared mode advanced-capability RAII lock guard for Mutex_sha...
bool in_open_open_range(T const &min_val, T const &val, T const &max_val)
Returns true if and only if the given value is within the given range, given as a (low,...
constexpr size_t DYNAMIC_EXTENT
Configures a Span at compile-time to have a variable, rather than constant, length (use it as templat...
bool in_open_closed_range(T const &min_val, T const &val, T const &max_val)
Returns true if and only if the given value is within the given range, given as a (low,...
boost::unique_lock< Mutex_non_recursive > Lock_guard_non_recursive
(Deprecated given C++1x) Short-hand for advanced-capability RAII lock guard for Mutex_non_recursive m...
void swap(Basic_blob< Allocator, SHARING > &blob1, Basic_blob< Allocator, SHARING > &blob2, log::Logger *logger_ptr) noexcept
Equivalent to blob1.swap(blob2).
boost::recursive_mutex Mutex_recursive
Short-hand for reentrant, exclusive mutex.
boost::unique_lock< Mutex_shared_non_recursive > Lock_guard_shared_non_recursive_ex
(Deprecated given C++1x) Short-hand for exclusive mode advanced-capability RAII lock guard for Mutex_...
boost::shared_lock< Mutex_noop_shared_non_recursive > Lock_guard_noop_shared_non_recursive_sh
(Deprecated given C++1x) Equivalent to Lock_guard_shared_non_recursive_sh but applied to Mutex_noop_s...
void ostream_op_to_string(std::string *target_str, T &&... ostream_args)
Writes to the specified string, as if the given arguments were each passed, via << in sequence,...
std::ostream & buffers_to_ostream(std::ostream &os, const Const_buffer_sequence &data, const std::string &indentation, size_t bytes_per_line)
Writes a multi- or single-line string representation of the provided binary data to an output stream,...
Task_engine::strand Strand
Short-hand for boost.asio strand, an ancillary class that works with Task_engine for advanced task sc...
bool in_closed_range(T const &min_val, T const &val, T const &max_val)
Returns true if and only if the given value is within the given range, inclusive.
boost::shared_ptr< void > Auto_cleanup
Helper type for setup_auto_cleanup().
boost::asio::io_context Task_engine
Short-hand for boost.asio event service, the central class of boost.asio.
boost::shared_lock< Shared_mutex > Shared_lock_guard
Short-hand for shared mode advanced-capability RAII lock guard, particuarly for Mutex_shared_non_recu...
std::string ostream_op_string(T &&... ostream_args)
Equivalent to ostream_op_to_string() but returns a new string by value instead of writing to the call...
boost::chrono::microseconds time_since_posix_epoch()
Get the current POSIX (Unix) time as a duration from the Epoch time point.
boost::unique_lock< Mutex_noop_shared_non_recursive > Lock_guard_noop_shared_non_recursive_ex
(Deprecated given C++1x) Equivalent to Lock_guard_shared_non_recursive_ex but applied to Mutex_noop_s...
boost::mutex Mutex_non_recursive
Short-hand for non-reentrant, exclusive mutex. ("Reentrant" = one can lock an already-locked-in-that-...
boost::asio::basic_waitable_timer< Fine_clock > Timer
boost.asio timer.
boost::null_mutex Mutex_noop_shared_non_recursive
Short-hand for a mutex type equivalent to util::Mutex_shared_non_recursive – except that the lock/unl...
boost::thread Thread
Short-hand for standard thread class.
boost::asio::ip::udp::endpoint Udp_endpoint
Short-hand for the UDP endpoint (IP/port) type.
constexpr Integer ceil_div(Integer dividend, Integer2 divisor)
Returns the result of the given non-negative integer divided by a positive integer,...