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:
2024-07-30 14:18:02 +03:00
parent f07c9cbce8
commit 1c7fc39b6c
58 changed files with 677 additions and 1191 deletions

View File

@@ -1,5 +1,6 @@
#include "dispatcherserver.h"
#include "piliterals_time.h"
#include "piscreentiles.h"
@@ -22,7 +23,7 @@ DispatcherServer::~DispatcherServer() {
void DispatcherServer::start() {
eth.listen(true);
timeout_timer.start(2000);
timeout_timer.start(0.5_Hz);
piCoutObj << "server started" << eth.readAddress();
}

View File

@@ -2,6 +2,7 @@
#define DISPATCHERSERVER_H
#include "cloudserver.h"
#include "pitimer.h"
class TileList;

View File

@@ -18,9 +18,14 @@
*/
#include "dispatcherserver.h"
#include "picrypt.h"
#include "picli.h"
#include "piconfig.h"
#include "pidir.h"
#include "piiostream.h"
#include "pip.h"
#include "piliterals_time.h"
#include "piscreen.h"
#include "piscreentiles.h"
#include "piscreentypes.h"
using namespace PICoutManipulators;
@@ -127,7 +132,7 @@ int main(int argc, char * argv[]) {
a.children()[0]->size_policy = PIScreenTypes::Fixed;
maintile.addTile(&a);
}
CONNECTL(&status_timer, tickEvent, [&](void *, int) {
CONNECTL(&status_timer, tickEvent, [&](int) {
screen.lock();
server.updateConnectionsTile(&conn_tl);
server.updateServersTile(&server_tl, sel_servers);
@@ -142,7 +147,7 @@ int main(int argc, char * argv[]) {
screen.rootTile()->addTile(new TilePICout());
screen.start();
server.start();
status_timer.start(100);
status_timer.start(10_Hz);
screen.waitForFinish();
} else {
PIKbdListener ls;
@@ -151,7 +156,7 @@ int main(int argc, char * argv[]) {
server.start();
if (cli.hasArgument("verbose")) {
CONNECTU(&status_timer, tickEvent, &server, picoutStatus);
status_timer.start(1000);
status_timer.start(1_Hz);
}
WAIT_FOR_EXIT
}

View File

@@ -26,6 +26,7 @@ int main(int argc, char * argv[]) {
# define PIP_CONSOLE_STATIC_DEFINE
# include "../../libs/console/piterminal.cpp"
# include "pifile.h"
# include "piliterals_time.h"
# include "pip_console_export.h"
# include "piscreentypes.h"
# include "pisharedmemory.h"
@@ -164,9 +165,12 @@ public:
PipeReader(): PIThread() {
wrote = readed = 0;
msg_size = 0;
start(1);
start(1_ms);
}
~PipeReader() {
stop();
if (!waitForFinish(100_ms)) terminate();
}
~PipeReader() { stop(); }
void run() {
in.resize(PIPE_BUFFER_SIZE);
ReadFile(pipe, in.data(), in.size_s(), &readed, 0);

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();

View File

@@ -17,9 +17,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "picli.h"
#include "pidatatransfer.h"
#include "piethernet.h"
#include "pifiletransfer.h"
#include "pip.h"
#include "piliterals_time.h"
#include "piscreen.h"
#include "piscreentiles.h"
@@ -52,7 +54,7 @@ public:
CONNECTU(&ft, receiveFilesFinished, this, ftevent);
}
CONNECT2(void, const uchar *, ssize_t, &eth, threadedReadEvent, this, received);
start(50);
start(20_Hz);
eth.setParameter(PIEthernet::SeparateSockets);
eth.startThreadedRead();
}
@@ -74,7 +76,7 @@ private:
PIEthernet eth;
bool quet_;
void tick(void *, int) override {
void tick(int) override {
if (ft.isStarted()) {
ftevent();
updatePMT();