|
BenBot 1.7.5
A chess engine
|
Topics | |
| General maths utilities | |
| Memory utilities | |
| String utilities | |
Files | |
| file | Chrono.hpp |
| file | Console.hpp |
| file | Files.hpp |
| file | Logger.hpp |
| file | Threading.hpp |
| file | Variant.hpp |
Namespaces | |
| namespace | util |
Concepts | |
| concept | util::ChronoDuration |
Classes | |
| struct | util::Visitor< Callable > |
Functions | |
| void | util::enable_utf8_console_output () |
| auto | util::files::load (const path &file) -> std::expected< std::string, std::string > |
| auto | util::files::overwrite (const path &file, std::string_view text) -> std::expected< void, std::string > |
| void | util::progressive_backoff (std::function< bool()> pred) |
| auto | util::start_file_logger (const std::filesystem::path &logFile) -> std::expected< void, std::string > |
General utilities not specifically related to chess.
| void util::enable_utf8_console_output | ( | ) |
Ensures that std::cout will interpret strings as UTF-8. On non-Windows platforms, this is a no-op.
|
nodiscard |
Loads the file's content as a string. If the file cannot be loaded, returns an explanatory error message.
|
nodiscard |
Overwrites the given filepath with the given text. If the file cannot be written, returns an explanatory error message.
| void util::progressive_backoff | ( | std::function< bool()> | pred | ) |
Blocks the calling thread until pred returns true. Blocking is implemented by spinning on the predicate and using a progressive backoff strategy.
This progressive backoff strategy avoids wasting energy, and allows other threads to make progress by yielding the waiting thread after a certain amount of time. This time is chosen to be about 1 millisecond.
On platforms other than x86, x86_64, or arm64, a simple implementation will be used.
|
nodiscard |
Starts a file logger. This works by duplicating std::cout and std::cerr output to a file at the given path. If the operation fails, returns an explanatory error string. This may be called multiple times with different file paths; each call will flush output to the previous log file and start writing output to the new log file.