version 4.0.0_alpha
in almost all methods removed timeouts in milliseconds, replaced to PISystemTime PITimer rewrite, remove internal impl, now only thread implementation, API similar to PIThread PITimer API no longer pass void* PIPeer, PIConnection improved stability on reinit and exit PISystemTime new methods pisd now exit without hanging
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "daemon.h"
|
||||
|
||||
#include "picrypt.h"
|
||||
#include "piliterals_time.h"
|
||||
#include "pisysteminfo.h"
|
||||
#include "shared.h"
|
||||
|
||||
@@ -23,6 +24,7 @@ Daemon::Remote::Remote(const PIString & n): PIThread() {
|
||||
|
||||
|
||||
Daemon::Remote::~Remote() {
|
||||
term_timer.stopAndWait();
|
||||
shellClose();
|
||||
ft.stop();
|
||||
stopAndWait();
|
||||
@@ -34,14 +36,14 @@ void Daemon::Remote::shellOpen() {
|
||||
piCoutObj << "shell open";
|
||||
term = new PITerminal();
|
||||
term->initialize();
|
||||
term_timer.start(50);
|
||||
term_timer.start(20_Hz);
|
||||
}
|
||||
|
||||
|
||||
void Daemon::Remote::shellClose() {
|
||||
if (!term) return;
|
||||
piCoutObj << "shell close";
|
||||
term_timer.stop();
|
||||
term_timer.stopAndWait();
|
||||
term->destroy();
|
||||
delete term;
|
||||
term = 0;
|
||||
@@ -272,7 +274,7 @@ Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_"
|
||||
localft.setCRCEnabled(false);
|
||||
CONNECTU(&localft, sendRequest, _self, received)
|
||||
dtimer.addDelimiter(5);
|
||||
dtimer.start(200);
|
||||
dtimer.start(5_Hz);
|
||||
|
||||
tile_root = new PIScreenTile();
|
||||
tile_root->direction = Vertical;
|
||||
@@ -320,6 +322,7 @@ Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_"
|
||||
|
||||
|
||||
Daemon::~Daemon() {
|
||||
dtimer.stopAndWait();
|
||||
requestCloseShell();
|
||||
PIVector<Remote *> rl = remotes.values();
|
||||
piForeach(Remote * r, rl) {
|
||||
@@ -547,7 +550,7 @@ void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVaria
|
||||
}
|
||||
|
||||
|
||||
void Daemon::timerEvent(void * _d, int delim) {
|
||||
void Daemon::timerEvent(int delim) {
|
||||
screen->lock();
|
||||
list_daemons->content.clear();
|
||||
availableDaemons();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define DAEMON_H
|
||||
|
||||
#include "file_manager.h"
|
||||
#include "pidatatransfer.h"
|
||||
#include "pifiletransfer.h"
|
||||
#include "pipeer.h"
|
||||
#include "piscreentiles.h"
|
||||
@@ -165,7 +164,7 @@ private:
|
||||
EVENT_HANDLER3(void, fmActionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data);
|
||||
EVENT_HANDLER(void, shResizeRequest);
|
||||
EVENT_HANDLER1(void, shKeyEvent, PIKbdListener::KeyEvent, k);
|
||||
EVENT_HANDLER2(void, timerEvent, void *, _d, int, delim);
|
||||
EVENT_HANDLER1(void, timerEvent, int, delim);
|
||||
EVENT_HANDLER2(void, filesReceived, const PIString &, p_name, bool, ok);
|
||||
EVENT_HANDLER2(void, filesSended, const PIString &, p_name, bool, ok);
|
||||
EVENT_HANDLER2(void, dirChanged, const PIString &, p_name, const PIString &, dir);
|
||||
|
||||
@@ -21,20 +21,19 @@
|
||||
#include "file_manager.h"
|
||||
#include "picli.h"
|
||||
#include "piintrospection_server.h"
|
||||
#include "piliterals_time.h"
|
||||
#include "piprocess.h"
|
||||
#include "pisingleapplication.h"
|
||||
#include "pisysteminfo.h"
|
||||
#include "pisystemmonitor.h"
|
||||
#include "shared.h"
|
||||
|
||||
class _Init {
|
||||
public:
|
||||
_Init() { randomize(); }
|
||||
};
|
||||
_Init _pisd_init;
|
||||
STATIC_INITIALIZER_BEGIN
|
||||
randomize();
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
PISystemMonitor sys_mon;
|
||||
PIScreen * screen = 0;
|
||||
PIScreen * screen = nullptr;
|
||||
|
||||
|
||||
class MainMenu: public PITimer {
|
||||
@@ -93,7 +92,7 @@ public:
|
||||
CONNECTU(screen, tileEvent, this, tileEvent)
|
||||
CONNECTU(screen, keyPressed, this, keyEvent)
|
||||
CONNECTU(&daemon_, menuRequest, this, menuRequest)
|
||||
start(25);
|
||||
start(40_Hz);
|
||||
}
|
||||
PIScreenTile * menuTile() {
|
||||
TileList * ret = new TileList();
|
||||
@@ -185,13 +184,19 @@ public:
|
||||
addrs_tl->content.clear();
|
||||
peerinfo_tl->content.clear();
|
||||
peermap_tl->content.clear();
|
||||
peers_tl->content << TileList::Row("this | 0 | 0 | " + PIString::fromNumber(daemon_.allPeers().size_s())
|
||||
// + " [em = " + PIString::fromBool(daemon_.lockedEth()) + ",
|
||||
//" "mm = " + PIString::fromBool(daemon_.lockedMBcasts()) + ", " "sm = " +
|
||||
//PIString::fromBool(daemon_.lockedSends()) + ", " "ms = " +
|
||||
//PIString::fromBool(daemon_.lockedMCSends()) + ", " "pm = " + PIString::fromBool(pm) + "]"
|
||||
,
|
||||
CellFormat());
|
||||
peers_tl->content << TileList::Row(
|
||||
"this | 0 | 0 | " + PIString::fromNumber(daemon_.allPeers().size_s())
|
||||
// + " [em = " + PIString::fromBool(daemon_.lockedEth()) + ",
|
||||
//" "mm = " + PIString::fromBool(daemon_.lockedMBcasts()) + ", "
|
||||
//"sm
|
||||
//=
|
||||
//"
|
||||
//+ PIString::fromBool(daemon_.lockedSends()) + ", " "ms = " +
|
||||
// PIString::fromBool(daemon_.lockedMCSends()) + ", " "pm = " + PIString::fromBool(pm)
|
||||
// +
|
||||
// "]"
|
||||
,
|
||||
CellFormat());
|
||||
piForeachC(PIPeer::PeerInfo & p, daemon_.allPeers())
|
||||
peers_tl->content << TileList::Row(p.name + " | d = " + PIString::fromNumber(p.dist) + " | p = " +
|
||||
PIString::fromNumber(p.ping()) + " | n = " + PIString::fromBool(p.isNeighbour()),
|
||||
@@ -246,7 +251,7 @@ public:
|
||||
}
|
||||
screen->unlock();
|
||||
}
|
||||
void tick(void * data_, int delimiter) override {
|
||||
void tick(int delimiter) override {
|
||||
if (tpeerdiag->visible || tpeer->visible) updatePeerInfo();
|
||||
if (tinfo->visible) updateSysMon();
|
||||
}
|
||||
@@ -420,7 +425,7 @@ int main(int argc, char * argv[]) {
|
||||
ls.enableExitCapture(PIKbdListener::F10);
|
||||
ls.start();
|
||||
WAIT_FOR_EXIT
|
||||
ls.stop();
|
||||
ls.stopAndWait();
|
||||
} else {
|
||||
screen->start();
|
||||
screen->waitForFinish();
|
||||
|
||||
Reference in New Issue
Block a user