-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.h
More file actions
41 lines (29 loc) · 778 Bytes
/
Logger.h
File metadata and controls
41 lines (29 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LOGGER_H
#define LOGGER_H
#include <pthread.h>
#include <cstdlib>
#include <unistd.h>
#include <string>
#include <sstream>
#include <iostream>
#include "ThreadManager.h"
using namespace std;
// This is a bit of a "meh" moment...
#define LOGBUFFERSIZE 100
// pthread_attr_setstacksize
class Logger : public Runnable {
public:
Logger();
~Logger();
void log(string str);
void run();
private:
string _buffer0[LOGBUFFERSIZE];
string _buffer1[LOGBUFFERSIZE];
unsigned int _top0;
unsigned int _top1;
unsigned int _bufferIndex;
pthread_mutex_t _logMutex;
void writeBuffer(string (&handleBuffer)[LOGBUFFERSIZE], unsigned int& handleTop);
};
#endif /* LOGGER_H */