add semaphore to cgastream
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "devices/CGA.h"
|
#include "devices/CGA.h"
|
||||||
#include "lib/OutStream.h"
|
#include "lib/OutStream.h"
|
||||||
|
#include "lib/Semaphore.h"
|
||||||
|
|
||||||
// NOTE: I added these classes to allow for easier stream-like color changing
|
// NOTE: I added these classes to allow for easier stream-like color changing
|
||||||
class fgc {
|
class fgc {
|
||||||
@ -51,18 +52,23 @@ class CGA_Stream : public OutStream, public CGA {
|
|||||||
private:
|
private:
|
||||||
CGA_Stream(CGA_Stream& copy) = delete; // Verhindere Kopieren
|
CGA_Stream(CGA_Stream& copy) = delete; // Verhindere Kopieren
|
||||||
|
|
||||||
|
Semaphore sem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGA::color color_fg;
|
CGA::color color_fg;
|
||||||
CGA::color color_bg;
|
CGA::color color_bg;
|
||||||
bool blink;
|
bool blink;
|
||||||
|
|
||||||
CGA_Stream() : color_fg(CGA::LIGHT_GREY), color_bg(CGA::BLACK), blink(false) {
|
CGA_Stream() : sem(1), color_fg(CGA::LIGHT_GREY), color_bg(CGA::BLACK), blink(false) {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
|
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
|
||||||
void flush() override;
|
void flush() override;
|
||||||
|
|
||||||
|
void lock() { sem.p(); }
|
||||||
|
void unlock() { sem.v(); }
|
||||||
|
|
||||||
// Change stream color
|
// Change stream color
|
||||||
template<typename T>
|
template<typename T>
|
||||||
// requires std::derived_from<T, CGA_Stream>
|
// requires std::derived_from<T, CGA_Stream>
|
||||||
|
|||||||
Reference in New Issue
Block a user