code format
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Single application
|
||||
Single application
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "pisingleapplication.h"
|
||||
|
||||
#include "pisharedmemory.h"
|
||||
|
||||
|
||||
@@ -60,22 +61,21 @@
|
||||
//!
|
||||
|
||||
|
||||
#define SHM_SIZE 1024*32
|
||||
#define SHM_SIZE 1024 * 32
|
||||
|
||||
|
||||
PISingleApplication::PISingleApplication(const PIString & app_name): PIThread() {
|
||||
first = true;
|
||||
first = true;
|
||||
started = false;
|
||||
sacnt = 0;
|
||||
shm = new PISharedMemory("sa_" + app_name, SHM_SIZE);
|
||||
sacnt = 0;
|
||||
shm = new PISharedMemory("sa_" + app_name, SHM_SIZE);
|
||||
start(100);
|
||||
}
|
||||
|
||||
|
||||
PISingleApplication::~PISingleApplication() {
|
||||
stop();
|
||||
if (!waitForFinish(5000))
|
||||
terminate();
|
||||
if (!waitForFinish(5000)) terminate();
|
||||
delete shm;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void PISingleApplication::sendMessage(const PIByteArray & m) {
|
||||
|
||||
void PISingleApplication::begin() {
|
||||
int cnt[2] = {0, 0};
|
||||
int tcnt = 0;
|
||||
int tcnt = 0;
|
||||
shm->read(cnt, 8);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
tcnt = cnt[0];
|
||||
@@ -113,7 +113,7 @@ void PISingleApplication::begin() {
|
||||
}
|
||||
piMSleep(100);
|
||||
}
|
||||
//piCoutObj << "started" << first << shm->size();
|
||||
// piCoutObj << "started" << first << shm->size();
|
||||
readed.reserve(shm->size());
|
||||
started = true;
|
||||
}
|
||||
@@ -124,8 +124,8 @@ void PISingleApplication::run() {
|
||||
++sacnt;
|
||||
int st_[2] = {sacnt, sacnt};
|
||||
shm->write(st_, 8);
|
||||
//piCoutObj << "write" << sacnt;
|
||||
int ri[3] = {0, 0, 0};
|
||||
// piCoutObj << "write" << sacnt;
|
||||
int ri[3] = {0, 0, 0};
|
||||
const int hdr_sz = sizeof(int) * 3;
|
||||
shm->read(ri, hdr_sz);
|
||||
if (ri[2] != 0 && ri[0] == ri[1]) {
|
||||
@@ -135,7 +135,7 @@ void PISingleApplication::run() {
|
||||
readed >> msg;
|
||||
if (!msg.isEmpty()) {
|
||||
messageReceived(msg);
|
||||
//piCoutObj << "message" << msg;
|
||||
// piCoutObj << "message" << msg;
|
||||
}
|
||||
int wi[3] = {sacnt, sacnt, 0};
|
||||
shm->write(wi, 12);
|
||||
|
||||
Reference in New Issue
Block a user