w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkServerEventLoop.cpp
Go to the documentation of this file.
1// $Id: RlinkServerEventLoop.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), use StopPending()
8// 2013-03-05 495 1.1.1 add exception catcher to EventLoop
9// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
10// 2013-01-12 474 1.0 Initial Version
11// ---------------------------------------------------------------------------
12
17#include <errno.h>
18
19#include "RlinkServer.hpp"
20#include "librtools/RlogMsg.hpp"
21
23
24using namespace std;
25
31// all method definitions in namespace Retro
32namespace Retro {
33
34//------------------------------------------+-----------------------------------
36
38 : fpServer(pserv)
39{}
40
41//------------------------------------------+-----------------------------------
43
45{}
46
47//------------------------------------------+-----------------------------------
49
51{
52 fUpdatePoll = true;
53
54 if (fspLog && fTraceLevel>0) fspLog->Write("eloop: starting", 'I');
55
56 try {
57 while (!StopPending()) {
58 int timeout = (fpServer->AttnPending() ||
59 fpServer->ActnPending()) ? 0 : -1;
60 int irc = DoPoll(timeout);
63 if (fPollFd.size() == 0) break;
64 if (irc > 0) DoCall();
65
68 }
69 } catch (exception& e) {
70 if (fspLog) {
71 RlogMsg lmsg(*fspLog, 'F');
72 lmsg << "eloop: crashed with exception: " << e.what();
73 }
74 return;
75 }
76
77 if (fspLog && fTraceLevel>0) fspLog->Write("eloop: stopped", 'I');
78
79 return;
80}
81
82} // end namespace Retro
std::shared_ptr< RlogFile > fspLog
log file ptr
Definition: ReventLoop.hpp:89
void DoCall(void)
FIXME_docs.
Definition: ReventLoop.cpp:259
std::vector< pollfd > fPollFd
Definition: ReventLoop.hpp:86
int DoPoll(int timeout=-1)
FIXME_docs.
Definition: ReventLoop.cpp:210
bool StopPending()
FIXME_docs.
Definition: ReventLoop.ipp:42
uint32_t fTraceLevel
trace level
Definition: ReventLoop.hpp:88
virtual ~RlinkServerEventLoop()
Destructor.
RlinkServerEventLoop(RlinkServer *pserv)
Default constructor.
virtual void EventLoop()
FIXME_docs.
bool AttnPending() const
FIXME_docs.
Definition: RlinkServer.ipp:93
void CallActnHandler()
FIXME_docs.
Rstats fStats
statistics
void CallAttnHandler()
FIXME_docs.
@ kStatNEloopPoll
event loop turns (poll)
@ kStatNEloopWait
event loop turns (wait)
bool ActnPending() const
FIXME_docs.
FIXME_docs.
Definition: RlogMsg.hpp:24
void Inc(size_t ind, double val=1.)
FIXME_docs.
Definition: Rstats.ipp:29
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47