List of all members | Public Member Functions | Protected Member Functions
casadi::UoutJournal Class Reference

Ipopt journal printing through casadi::uout() More...

#include <ipopt_uout_journal.hpp>

Detailed Description

uout() is thread_local, so the stream is looked up at every write rather than stored: a StreamJournal holding &uout() keeps pointing at the stream of the thread that created the solver memory, which is destroyed when that thread exits (e.g. a map(..., "thread") worker). The next solve on another thread then crashes in Journalist::FlushBuffer, even with printing disabled.

Shared by the ipopt and bonmin plugins (header-only).

Definition at line 49 of file ipopt_uout_journal.hpp.

Inheritance diagram for casadi::UoutJournal:
Inheritance graph
[legend]
Collaboration diagram for casadi::UoutJournal:
Collaboration graph
[legend]

Public Member Functions

 UoutJournal (const std::string &name, Ipopt::EJournalLevel default_level)
 

Protected Member Functions

void PrintImpl (Ipopt::EJournalCategory, Ipopt::EJournalLevel, const char *str) override
 
void PrintfImpl (Ipopt::EJournalCategory, Ipopt::EJournalLevel, const char *pformat, va_list ap) override
 
void FlushBufferImpl () override
 

Constructor & Destructor Documentation

◆ UoutJournal()

casadi::UoutJournal::UoutJournal ( const std::string &  name,
Ipopt::EJournalLevel  default_level 
)
inline

Definition at line 51 of file ipopt_uout_journal.hpp.

52  : Ipopt::Journal(name, default_level) {}

Member Function Documentation

◆ FlushBufferImpl()

void casadi::UoutJournal::FlushBufferImpl ( )
inlineoverrideprotected

Definition at line 71 of file ipopt_uout_journal.hpp.

71  {
72  uout().flush();
73  }
std::ostream & uout()

References casadi::uout().

◆ PrintfImpl()

void casadi::UoutJournal::PrintfImpl ( Ipopt::EJournalCategory  ,
Ipopt::EJournalLevel  ,
const char *  pformat,
va_list  ap 
)
inlineoverrideprotected

Definition at line 59 of file ipopt_uout_journal.hpp.

60  {
61  va_list ap2;
62  va_copy(ap2, ap);
63  int n = std::vsnprintf(nullptr, 0, pformat, ap2);
64  va_end(ap2);
65  if (n < 0) return;
66  std::vector<char> buf(n + 1);
67  std::vsnprintf(buf.data(), buf.size(), pformat, ap);
68  uout() << buf.data();
69  }

References casadi::uout().

◆ PrintImpl()

void casadi::UoutJournal::PrintImpl ( Ipopt::EJournalCategory  ,
Ipopt::EJournalLevel  ,
const char *  str 
)
inlineoverrideprotected

Definition at line 55 of file ipopt_uout_journal.hpp.

55  {
56  uout() << str;
57  }
std::string str(const T &v)
String representation, any type.

References casadi::str(), and casadi::uout().


The documentation for this class was generated from the following file: