8 #ifndef INCL_evo_iothread_h 9 #define INCL_evo_iothread_h 45 #define EVO_CONSOLE_MT static evo::ConsoleMT& c = evo::con_mt() 70 #define EVO_IO_MT(STREAM, CODE) { Mutex::Lock evo_streamlock_(STREAM .mutex); STREAM.stream CODE; } 92 #if EVO_CATCH_DEBUG == 0 93 #define EVO_CATCH_MT(CODE) catch (const evo::Exception& e) { \ 95 evo::ConsoleMT& c = evo::con_mt(); \ 96 Mutex::Lock lock(c.err.mutex); \ 97 c.err.stream << evo::NL << e.msg() << " -- "; \ 98 evo::errormsg_out(c.err.stream, e.error()); \ 99 c.err.stream << evo::NL; \ 104 #define EVO_CATCH_MT(CODE) catch (const evo::Exception& e) { \ 106 evo::ConsoleMT& c = evo::con_mt(); \ 107 Mutex::Lock lock(c.err.mutex); \ 108 c.err.stream << evo::NL; \ 110 c.err.stream << e.file() << '(' << e.line() << evo::SubString("): ", 3); \ 111 c.err.stream << e.msg() << evo::SubString(" -- ", 4); \ 112 evo::errormsg_out(c.err.stream, e.error()); \ 113 c.err.stream << evo::NL; \ 147 This& operator=(This&);
167 stream(path, mode, flushlines, nl, exceptions)
172 This& operator=(This&);
StreamMT< T > This
This type.
Definition: iothread.h:134
Mutex mutex
Stream mutex.
Definition: iothread.h:158
File stream
Stream object.
Definition: iothread.h:159
OutT err
Write to console, error output.
Definition: iothread.h:214
StreamMT(bool exceptions=1)
Constructor.
Definition: iothread.h:142
Console & con()
Shortcut for Console::get().
Definition: io.h:1015
Console I/O.
Definition: io.h:972
StreamMT< PipeOut > PipeOutMT
Output pipe with mutex for synchonization – see StreamMT.
Definition: iothread.h:176
Multithreaded console I/O.
Definition: iothread.h:206
StreamMT(const char *path, Open mode=oREAD, bool flushlines=false, Newline nl=NL_SYS, bool exceptions=1)
Constructor to open file.
Definition: iothread.h:166
Open
Open mode for files and streams.
Definition: sysio.h:190
Newline
Newline type.
Definition: sys.h:748
Evo File I/O stream class.
StreamMT< File > This
This type.
Definition: iothread.h:156
Evo I/O streams and Console I/O.
PipeOut err
Write to console, error output.
Definition: io.h:979
Mutex for thread synchronization.
Definition: thread.h:104
InT in
Read console input.
Definition: iothread.h:212
StreamMT(Newline nl=NL, bool exceptions=1)
Constructor.
Definition: iothread.h:162
Evo threads implementation.
#define EVO_EXCEPTIONS
Whether to throw exceptions on error by default.
Definition: evo_config.h:35
ConsoleMT & con_mt()
Shortcut for ConsoleMT::get().
Definition: iothread.h:233
Mutex mutex
Stream mutex.
Definition: iothread.h:136
Read only.
Definition: sysio.h:191
Smart locking for synchronization.
Definition: lock.h:28
File I/O stream.
Definition: file.h:77
PipeOut::Format Format
Stream output formatter with state.
Definition: iothread.h:207
StreamExtMT< PipeOut, Mutex > OutT
Output type.
Definition: iothread.h:209
static const NewlineDefault & NL
Default newline type.
Definition: sys.h:785
T stream
Stream object.
Definition: iothread.h:137
Mutex::Lock Lock
Mutex lock type.
Definition: iothread.h:210
PipeIn in
Read console input.
Definition: io.h:977
Evo C++ Library namespace.
Definition: alg.h:11
PipeOut out
Write to console, normal output.
Definition: io.h:978
StreamExtMT< PipeIn, Mutex > InT
Input type.
Definition: iothread.h:208
OutT out
Write to console, normal output.
Definition: iothread.h:213
static ConsoleMT & get()
Get console instance to use.
Definition: iothread.h:219
static const Newline NL_SYS
Current system newline type.
Definition: sys.h:763
Stream with mutex for multithreaded synchronization.
Definition: iothread.h:133
StreamMT< PipeIn > PipeInMT
Input pipe with mutex for synchonization – see StreamMT.
Definition: iothread.h:175
StreamMT< File > FileMT
File with mutex for synchonization – see File and StreamMT<File>
Definition: iothread.h:177
Stream with mutex for multithreaded synchronization, specialized for File.
Definition: iothread.h:155