1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/monitor/ZoneReader.cpp
10 #include "monitor/ZoneReader.h"
11 #include "shm/PacketHeader.h"
12 #include "util/MessageSystem.h"
16 ZoneReader::ZoneReader(SHMReader
*shmReader
) : m_shmReader(shmReader
) {
20 ZoneReader::~ZoneReader() {
24 void ZoneReader::run() {
28 void ZoneReader::start() {
29 pthread_create(&m_threadID
, NULL
, run
, this);
32 void ZoneReader::wait() {
33 pthread_join(m_threadID
, NULL
);
36 void *ZoneReader::run(void *voidInstance
) {
37 Message(Debug
, "Beginning ZoneReader loop . . .");
38 ZoneReader
*instance
= static_cast<ZoneReader
*>(voidInstance
);
39 SHMReader
*reader
= instance
->m_shmReader
;
40 SHMReader::ReadBroker broker
;
43 reader
->waitForPacket();
44 int32_t zone
= reader
->zoneWithData();
47 SHM::PacketHeader
*packetHeader
;
48 broker
.setupRequest(zone
, sizeof(SHM::PacketHeader
));
49 reader
->processRequest(broker
);
50 packetHeader
= static_cast<SHM::PacketHeader
*>(broker
.data());
53 broker
.setupRequest(zone
, packetHeader
->packetSize
);
54 reader
->processRequest(broker
);
55 packetData
= static_cast<uint8_t *>(broker
.data());
57 Message(Log
, "Recieved packet from module " << packetHeader
->moduleID
<< ", size " << packetHeader
->packetSize
);
62 Message(Debug
, "Ending ZoneReader loop . . .");
67 } // namespace Monitor