51 lockclr(this->m_lock);
58 lockclr(this->m_lock);
59 lockret(this->m_lock);
67 return -1 != this->m_lock;
81 while (lockset(this->m_lock));
82 lockclr(this->m_lock);
83 lockret(this->m_lock);
86 this->m_lock = locknew();
98 while (lockset(this->m_lock));
99 this->m_borrowed =
true;
100 return this->m_printer;
107 if (printer == this->m_printer) {
108 lockclr(this->m_lock);
109 this->m_borrowed =
false;
120 while (lockset(this->m_lock));
121 this->m_printer->
print(var);
122 lockclr(this->m_lock);
131 while (lockset(this->m_lock));
132 this->m_printer->
println(
string);
133 lockclr(this->m_lock);
140 while (lockset(this->m_lock));
141 this->m_printer->
puts(fmt);
142 lockclr(this->m_lock);
148 template<
typename T,
typename... Targs>
149 void printf (
const char fmt[],
const T first,
const Targs... remaining)
const {
150 while (lockset(this->m_lock));
151 this->m_printer->
printf(fmt, first, remaining...);
152 lockclr(this->m_lock);
Generic definitions and functions for the Parallax Propeller.
~SynchronousPrinter()
Ensure that, when a SynchronousPrinter is no longer being used, the lock is returned.
void print(const T var) const
const PropWare::SynchronousPrinter pwSyncOut
Global and shared instance for easy printing to the terminal (thread safe)
void printf(const char fmt[], const T first, const Targs...remaining) const
Similar in functionality to the C-standard function printf.
Container class that has formatting methods for human-readable output. This class can be constructed ...
void puts(const char string[]) const
Send a null-terminated character array.
void println(const char string[]) const
Print a string along with a newline at the end.
SynchronousPrinter(const Printer *printer)
Creates a synchronous instance of a Printer that can be used from multiple cogs simultaneously.
bool has_lock() const
Determine if an instance of a SynchronousPrinter successfully retrieved a lock.
void printf(const char fmt[]) const
const Printer * borrow_printer()
Retrieve the printer and acquire the lock. Useful when a class that only supports Printer and not Syn...
bool refreshLock()
Retrieve a new lock.
Print formatted text to a serial terminal, an LCD, or any other device from any cog at any time with ...
bool return_printer(const Printer *printer)
After calling SynchronousPrinter::borrow_printer, this method.
void printf(const char fmt[], const T first, const Targs...remaining) const
void print(const char c, const Format format=DEFAULT_FORMAT) const
Print a single character.
void println(const char string[]) const
Print a null-terminated string followed by a newline (' ')