mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-06 09:12:20 +00:00
new: hardware_concurrency helper
Co-authored-by: Lorenzo Fontana <lo@linux.com> Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
committed by
poiana
parent
3d1f27d082
commit
75e62269c3
@@ -52,6 +52,12 @@ std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t ind
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t hardware_concurrency()
|
||||||
|
{
|
||||||
|
auto hc = std::thread::hardware_concurrency();
|
||||||
|
return hc ? hc : 1;
|
||||||
|
}
|
||||||
|
|
||||||
void readfile(const std::string& filename, std::string& data)
|
void readfile(const std::string& filename, std::string& data)
|
||||||
{
|
{
|
||||||
std::ifstream file(filename.c_str(), std::ios::in);
|
std::ifstream file(filename.c_str(), std::ios::in);
|
||||||
|
@@ -21,6 +21,7 @@ limitations under the License.
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <nonstd/string_view.hpp>
|
#include <nonstd/string_view.hpp>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -34,6 +35,9 @@ namespace utils
|
|||||||
std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t indent, uint32_t line_len);
|
std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t indent, uint32_t line_len);
|
||||||
|
|
||||||
void readfile(const std::string& filename, std::string& data);
|
void readfile(const std::string& filename, std::string& data);
|
||||||
|
|
||||||
|
uint32_t hardware_concurrency();
|
||||||
|
|
||||||
namespace network
|
namespace network
|
||||||
{
|
{
|
||||||
static const std::string UNIX_SCHEME("unix://");
|
static const std::string UNIX_SCHEME("unix://");
|
||||||
|
Reference in New Issue
Block a user