8 #if defined(__CYGWIN__) || defined(_WIN32) 11 #include <semaphore.h> 14 #define STAT_EX_SIZE 175 15 #define PLAY_EX_SIZE 2+6*SIMUL_TRACKS 29 void down(
long long int bytes);
31 void up(
long long int bytes);
33 void host(std::string name);
39 void crc(
unsigned int sum);
63 semaphore(
const char * name,
int oflag, mode_t mode,
unsigned int value);
65 operator bool()
const;
66 void open(
const char * name,
int oflag, mode_t mode = 0,
unsigned int value = 0);
71 bool tryWaitOneSecond();
75 #if defined(__CYGWIN__) || defined(_WIN32) 76 static SECURITY_ATTRIBUTES getSecurityAttributes();
98 sharedFile(std::string name_ =
"",
unsigned int len_ = 0,
bool master_ =
false,
bool autoBackoff =
true);
101 operator bool()
const;
102 void init(std::string name_,
unsigned int len_,
bool master_ =
false,
bool autoBackoff =
true);
105 return name < rhs.
name;
121 #if defined(__CYGWIN__) || defined(_WIN32) 122 void preservePage(std::string);
123 void releasePage(std::string);
130 sharedPage(std::string name_ =
"",
unsigned int len_ = 0,
bool master_ =
false,
bool autoBackoff =
true);
133 operator bool()
const;
134 void init(std::string name_,
unsigned int len_,
bool master_ =
false,
bool autoBackoff =
true);
136 bool operator < (
const sharedPage & rhs)
const {
137 return name < rhs.
name;
141 #if defined(__CYGWIN__) || defined(_WIN32) 162 sharedPage(std::string name_ =
"",
unsigned int len_ = 0,
bool master_ =
false,
bool autoBackoff =
true);
180 sharedServer(std::string name,
int len,
bool withCounter =
false);
181 void init(std::string name,
int len,
bool withCounter =
false);
183 void parseEach(
void (*callback)(
char *
data,
size_t len,
unsigned int id));
184 operator bool()
const;
188 bool isInUse(
unsigned int id);
216 sharedClient(std::string name,
int len,
bool withCounter =
false);
219 void write(
char *
data,
int len);
241 unsigned long getTrackId(
size_t offset)
const;
242 void setTrackId(
size_t offset,
unsigned long trackId)
const;
243 unsigned long getKeynum(
size_t offset)
const;
244 void setKeynum(
size_t offset,
unsigned long keynum);
long time()
Gets time currently connected.
Definition: shared_memory.cpp:618
A class used as a semaphore guard.
Definition: shared_memory.h:86
semaphore * mySemaphore
The semaphore to guard.
Definition: shared_memory.h:92
char * data
Definition: shared_memory.h:246
A class used for the abstraction of semaphores.
Definition: shared_memory.h:60
long long int up()
Gets the amount of bytes sent.
Definition: shared_memory.cpp:654
semaphore mySemaphore
A semaphore that is locked upon creation and deletion of the page, to ensure no new data is allocated...
Definition: shared_memory.h:198
long lastSecond()
Gets the last viewing second of this user.
Definition: shared_memory.cpp:630
unsigned int amount
The amount of connected clients.
Definition: shared_memory.h:186
int handle
The fd handle of the opened shared file.
Definition: shared_memory.h:110
unsigned int payLen
The length of each consecutive piece of payload.
Definition: shared_memory.h:194
std::set< sharedPage > myPages
The set of sharedPage structures to manage the actual memory.
Definition: shared_memory.h:196
std::string baseName
The basename of the shared pages.
Definition: shared_memory.h:225
The server part of a server/client model for shared memory.
Definition: shared_memory.h:177
bool master
Whether this class should unlink the shared file upon deletion or not.
Definition: shared_memory.h:116
int offsetOnPage
The offset of the payload reserved for this client within the opened page.
Definition: shared_memory.h:233
int payLen
The size in bytes of the opened page.
Definition: shared_memory.h:231
void wait(int ms)
Sleeps for the indicated amount of milliseconds or longer.
Definition: timing.cpp:32
semaphore mySemaphore
A semaphore that is locked upon trying to allocate space on a page.
Definition: shared_memory.h:229
statExchange(char *_data)
StatExchange constructor, sets the datapointer to the given value.
Definition: shared_memory.cpp:598
A class for managing shared files.
Definition: shared_memory.h:96
long long int now()
Gets timestamp of the current stats.
Definition: shared_memory.cpp:606
unsigned int crc()
Gets checksum field.
Definition: shared_memory.cpp:703
sharedPage myPage
The shared page this client has reserved a space on.
Definition: shared_memory.h:227
bool hasCounter
Whether the payload has a counter, if so, it is added in front of the payload.
Definition: shared_memory.h:200
std::string host()
Gets the host of this connection.
Definition: shared_memory.cpp:669
Definition: shared_memory.cpp:25
long long int down()
Gets the amount of bytes received.
Definition: shared_memory.cpp:642
The client part of a server/client model for shared memory.
Definition: shared_memory.h:212
char getSync()
Gets checksum field.
Definition: shared_memory.cpp:715
std::string myName
Definition: shared_memory.h:82
char * mapped
A pointer to the payload of the file file.
Definition: shared_memory.h:118
sem_t * mySem
Definition: shared_memory.h:80
function init(plot)
Definition: jquery.flot.time.min.js:1
char * data
The payload for the stat exchange.
Definition: shared_memory.h:56
long long int len
The size in bytes of the opened shared file.
Definition: shared_memory.h:114
void setSync(char s)
Sets checksum field.
Definition: shared_memory.cpp:710
std::string streamName()
Gets the name of the stream this user is viewing.
Definition: shared_memory.cpp:683
A class for handling shared memory pages.
Definition: shared_memory.h:160
A class used for the exchange of statistics over shared memory.
Definition: shared_memory.h:20
std::string name
The name of the opened shared file.
Definition: shared_memory.h:112
Definition: shared_memory.h:238
std::string connector()
Gets the name of the connector through which this user is viewing.
Definition: shared_memory.cpp:693
bool hasCounter
Whether the payload has a counter, if so, it is added in front of the payload.
Definition: shared_memory.h:235
std::string baseName
The basename of the shared pages.
Definition: shared_memory.h:192