2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file monitor/src/program/Link.cpp
14 #include "program/Link.h"
19 Link::Link(std::string name
, uint32_t size
) : m_sharedMemory(NULL
) {
20 m_sharedMemory
= new SharedMemory(name
, size
);
24 std::cout
<< "Link destructing . . ." << std::endl
;
28 std::cout
<< "Link: creating thread . . ." << std::endl
;
29 pthread_create(&m_threadID
, NULL
, run
, NULL
);
32 void Link::terminate() {
33 std::cout
<< "Link::terminate() called . . .\n";
35 if(m_sharedMemory
!= NULL
) {
36 std::cout
<< "m_sharedMemory is not NULL, sending termination notice . . ." << std::endl
;
37 m_sharedMemory
->notifyTermination();
40 std::cout
<< "Link::terminate(): joining thread . . ." << std::endl
;
41 pthread_join(m_threadID
, NULL
);
44 void *Link::run(void *voidInstance
) {
45 std::cout
<< "Link::run() . . ." << std::endl
;
46 Link
*instance
= reinterpret_cast<Link
*>(voidInstance
);
48 Packet
*packet
= NULL
;
50 while((packet
= instance
->m_sharedMemory
->readNext()) != NULL
) {
51 std::cout
<< "Received packet!" << std::endl
;
54 std::cout
<< "Link::run() read loop ended. NULL packet recieved." << std::endl
;
56 delete instance
->m_sharedMemory
;
57 instance
->m_sharedMemory
= NULL
;
62 } // namespace Program
63 } // namespace Monitor