hurryUp()
This commit is contained in:
+24
-2
@@ -137,8 +137,12 @@ const Config& Context::config() const
|
||||
return pvt->effective;
|
||||
}
|
||||
|
||||
void Context::poke()
|
||||
{}
|
||||
void Context::hurryUp()
|
||||
{
|
||||
pvt->tcp_loop.call([this](){
|
||||
pvt->poke();
|
||||
});
|
||||
}
|
||||
|
||||
static
|
||||
Value buildCAMethod()
|
||||
@@ -251,6 +255,24 @@ void Context::Pvt::close()
|
||||
});
|
||||
}
|
||||
|
||||
void Context::Pvt::poke()
|
||||
{
|
||||
epicsTimeStamp now{};
|
||||
|
||||
double age = -1.0;
|
||||
if(epicsTimeGetCurrent(&now) || (age=epicsTimeDiffInSeconds(&now, &lastPoke))<30.0) {
|
||||
log_debug_printf(setup, "Ignoring hurryUp() age=%.1f sec\n", age);
|
||||
return;
|
||||
}
|
||||
lastPoke = now;
|
||||
|
||||
log_debug_printf(setup, "hurryUp()%s\n", "");
|
||||
|
||||
timeval immediate{0,0};
|
||||
if(event_add(searchTimer.get(), &immediate))
|
||||
throw std::runtime_error("Unable to schedule searchTimer");
|
||||
}
|
||||
|
||||
bool Context::Pvt::onSearch()
|
||||
{
|
||||
searchMsg.resize(0x10000);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <epicsTime.h>
|
||||
|
||||
#include <pvxs/client.h>
|
||||
|
||||
#include "evhelper.h"
|
||||
@@ -133,6 +135,8 @@ struct Context::Pvt
|
||||
evsocket searchTx;
|
||||
uint16_t searchRxPort;
|
||||
|
||||
epicsTimeStamp lastPoke{};
|
||||
|
||||
std::vector<uint8_t> searchMsg;
|
||||
|
||||
// search destination address and whether to set the unicast flag
|
||||
@@ -157,6 +161,8 @@ struct Context::Pvt
|
||||
|
||||
void close();
|
||||
|
||||
void poke();
|
||||
|
||||
bool onSearch();
|
||||
static void onSearchS(evutil_socket_t fd, short evt, void *raw);
|
||||
void tickSearch();
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public:
|
||||
const Config& config() const;
|
||||
|
||||
//! Request prompt search of any disconnected channels
|
||||
void poke();
|
||||
void hurryUp();
|
||||
|
||||
Request request() const;
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ int main(int argc, char *argv[])
|
||||
.exec());
|
||||
}
|
||||
|
||||
// expedite search after starting all requests
|
||||
ctxt.hurryUp();
|
||||
|
||||
SigInt sig([&done]() {
|
||||
done.signal();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user