53 : fStopPending(false),
79 for (
size_t i=0; i<
fPollDsc.size(); i++) {
82 throw Rexception(
"ReventLoop::AddPollHandler()",
83 "Bad args: duplicate handler");
87 fPollDsc.emplace_back(move(pollhdl),fd,events);
92 lmsg <<
"eloop: add handler: " << fd <<
"," <<
RosPrintf(events,
"x");
105 for (
size_t i=0; i<
fPollDsc.size(); i++) {
112 lmsg <<
"eloop: remove handler: " << fd <<
"," <<
RosPrintf(events,
"x");
117 if (!nothrow)
throw Rexception(
"ReventLoop::RemovePollHandler()",
118 "Bad args: unknown handler");
128 for (
size_t i=0; i<
fPollDsc.size(); i++) {
144 for (
size_t i=0; i<
fPollDsc.size(); i++) {
164 if (
fPollFd.size() == 0)
break;
167 }
catch (exception& e) {
170 lmsg <<
"eloop: crashed with exception: " << e.what();
185 os << bl << (text?text:
"--") <<
"ReventLoop @ " <<
this << endl;
190 os << bl <<
" fPollDsc.size: " <<
fPollDsc.size() << endl;
191 os << bl <<
" fPollFd.size: " <<
fPollFd.size() << endl;
192 os << bl <<
" fPollHdl.size: " <<
fPollHdl.size() << endl;
193 for (
size_t i=0; i<
fPollDsc.size(); i++) {
194 os << bl <<
" [" <<
RosPrintf(i,
"d",3) <<
"]:"
197 <<
" hdl:" << bool(
fPollDsc[i].fHandler)
201 os << bl <<
" fTraveLevel: " <<
fTraceLevel << endl;
202 os << bl <<
" fspLog: " <<
fspLog.get() << endl;
219 for (
size_t i=0; i<
fPollDsc.size(); i++) {
229 lmsg <<
"eloop: redo pollfd list, size=" <<
fPollDsc.size() << endl;
233 if (
fPollFd.size() == 0)
return 0;
235 if (irc < 0 && errno == EINTR)
return 0;
237 throw Rexception(
"ReventLoop::EventLoop()",
"poll() failed: ", errno);
241 lmsg <<
"eloop: poll(): rc=" << irc;
242 for (
size_t i=0; i<
fPollFd.size(); i++) {
243 if (
fPollFd[i].revents == 0)
continue;
261 for (
size_t i=0; i<
fPollFd.size(); i++) {
269 lmsg <<
"eloop: handler(" <<
fPollFd[i].fd
272 <<
" and requested removal";
virtual void EventLoop()
FIXME_docs.
std::shared_ptr< RlogFile > fspLog
log file ptr
virtual ~ReventLoop()
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
void DoCall(void)
FIXME_docs.
std::vector< pollfd > fPollFd
int DoPoll(int timeout=-1)
FIXME_docs.
void AddPollHandler(pollhdl_t &&pollhdl, int fd, short events=POLLIN)
FIXME_docs.
std::vector< PollDsc > fPollDsc
bool StopPending()
FIXME_docs.
uint32_t fTraceLevel
trace level
std::function< int(const pollfd &)> pollhdl_t
bool TestPollHandler(int fd, short events=POLLIN)
FIXME_docs.
std::vector< pollhdl_t > fPollHdl
void RemovePollHandler(int fd, short events, bool nothrow=false)
FIXME_docs.
I/O appicator to generate fill characters.
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Declaration of class ReventLoop.