Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <message_callback_data.h>
Public Member Functions | |
BufferedMessageCallback (SolverInterface::MessageCallback user_message_callback) | |
bool | has_user_message_callback () const |
void | OnMessage (absl::string_view message) |
void | Flush () |
Buffers callback data into lines using MessageCallbackData and invokes the callback as new lines are ready.
In MathOpt, typically used for solvers that provide a callback with the solver logs where the logs contain \n
characters and messages may be both less than a complete line or multiple lines. Recommended use:
If initialized with a nullptr for the user callback, all functions on this class have no effect.
This class is threadsafe if the input callback is also threadsafe.
Definition at line 81 of file message_callback_data.h.
|
explicit |
Definition at line 65 of file message_callback_data.cc.
void operations_research::math_opt::BufferedMessageCallback::Flush | ( | ) |
If the buffer has any pending message, sends it to the callback. This function has no effect if called when the buffer is empty. Calling this function when the buffer is non-empty before the stream of logs is complete will result in the user getting extra line breaks.
Do not hold lock during callback to user code.
Definition at line 84 of file message_callback_data.cc.
|
inline |
If false, incoming messages are ignored and OnMessage() and Flush() have no effect.
Definition at line 88 of file message_callback_data.h.
void operations_research::math_opt::BufferedMessageCallback::OnMessage | ( | absl::string_view | message | ) |
Appends message
to the buffer, then invokes the callback once on all newly complete lines and removes those lines from the buffer. In particular, the callback is not invoked if message does not contain any \n
.
Do not hold lock during callback to user code.
Definition at line 69 of file message_callback_data.cc.