26 static inline bool operator<(
const timespec &t1,
const timespec &t2 )
28 return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_nsec < t2.tv_nsec);
31 static inline bool operator<=(
const timespec &t1,
const timespec &t2 )
33 return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_nsec <= t2.tv_nsec);
36 static inline timespec &
operator+=( timespec &t1,
const timespec &t2 )
38 t1.tv_sec += t2.tv_sec;
39 if ( (t1.tv_nsec += t2.tv_nsec) >= 1000000000 )
42 t1.tv_nsec -= 1000000000;
47 static inline timespec
operator+(
const timespec &t1,
const timespec &t2 )
50 tmp.tv_sec = t1.tv_sec + t2.tv_sec;
51 if ( (tmp.tv_nsec = t1.tv_nsec + t2.tv_nsec) >= 1000000000 )
54 tmp.tv_nsec -= 1000000000;
59 static inline timespec
operator-(
const timespec &t1,
const timespec &t2 )
62 tmp.tv_sec = t1.tv_sec - t2.tv_sec;
63 if ( (tmp.tv_nsec = t1.tv_nsec - t2.tv_nsec) < 0 )
66 tmp.tv_nsec += 1000000000;
71 static inline timespec
operator-=( timespec &t1,
const timespec &t2 )
73 t1.tv_sec -= t2.tv_sec;
74 if ( (t1.tv_nsec -= t2.tv_nsec) < 0 )
77 t1.tv_nsec += 1000000000;
82 static inline timespec &
operator+=( timespec &t1,
const long msek )
84 t1.tv_sec += msek / 1000;
85 if ( (t1.tv_nsec += (msek % 1000) * 1000000) >= 1000000000 )
88 t1.tv_nsec -= 1000000000;
93 static inline timespec
operator+(
const timespec &t1,
const long msek )
96 tmp.tv_sec = t1.tv_sec + msek / 1000;
97 if ( (tmp.tv_nsec = t1.tv_nsec + (msek % 1000) * 1000000) >= 1000000000 )
100 tmp.tv_nsec -= 1000000;
105 static inline timespec
operator-(
const timespec &t1,
const long msek )
108 tmp.tv_sec = t1.tv_sec - msek / 1000;
109 if ( (tmp.tv_nsec = t1.tv_nsec - (msek % 1000)*1000000) < 0 )
112 tmp.tv_nsec += 1000000000;
117 static inline timespec
operator-=( timespec &t1,
const long msek )
119 t1.tv_sec -= msek / 1000;
120 if ( (t1.tv_nsec -= (msek % 1000) * 1000000) < 0 )
123 t1.tv_nsec += 1000000000;
131 clock_gettime(CLOCK_MONOTONIC, &now);
133 if (diff.tv_sec > 2000)
134 return 2000 * 1000 * 1000;
135 return diff.tv_sec * 1000000 + diff.tv_nsec / 1000;
191 std::map<int, eSocketNotifier*> notifiers;
196 int m_interrupt_requested;
197 timespec m_twisted_timer;
203 int processOneEvent(
long user_timeout, PyObject **res=0,
ePyObject additional=
ePyObject());
207 void removeTimer(
eTimer* e);
212 :app_quit_now(0), retval(0), m_inActivate(0), m_interrupt_requested(0)
219 void quit(
int ret=0);
239 virtual int _poll(
struct pollfd *fds, nfds_t nfds,
int timeout);
254 m_is_idle(0), m_idle_count(0)
266 int _poll(
struct pollfd *fds, nfds_t nfds,
int timeout);
282 timespec nextActivation;
305 bool needsActivation() { timespec now; clock_gettime(CLOCK_MONOTONIC, &now);
return nextActivation <= now; }
307 void start(
long msec,
bool b=
false);
The application class.
Definition: ebase.h:249
eApplication()
Definition: ebase.h:253
int _poll(struct pollfd *fds, nfds_t nfds, int timeout)
Definition: ebase.cpp:400
~eApplication()
Definition: ebase.h:259
int idleCount() const
Definition: ebase.h:264
int isIdle() const
Definition: ebase.h:263
int runLoop()
Definition: ebase.cpp:356
friend class eTimer
Definition: ebase.h:188
void interruptPoll()
Definition: ebase.cpp:384
int iterate(unsigned int timeout=0, PyObject **res=0, SWIG_PYOBJECT(ePyObject) additional=(PyObject *) 0)
Definition: ebase.cpp:318
eMainloop()
Definition: ebase.h:211
friend class eSocketNotifier
Definition: ebase.h:189
void reset()
Definition: ebase.cpp:363
virtual ~eMainloop()
Definition: ebase.cpp:132
PyObject * poll(SWIG_PYOBJECT(ePyObject) dict, SWIG_PYOBJECT(ePyObject) timeout)
Definition: ebase.cpp:368
void quit(int ret=0)
Definition: ebase.cpp:389
virtual int _poll(struct pollfd *fds, nfds_t nfds, int timeout)
Definition: ebase.cpp:395
void push_back(T *)
Definition: eptrlist.h:458
Gives a callback when data on a file descriptor is ready.
Definition: ebase.h:146
@ Priority
Definition: ebase.h:150
@ Read
Definition: ebase.h:150
@ Write
Definition: ebase.h:150
@ Hungup
Definition: ebase.h:150
@ Error
Definition: ebase.h:150
void start()
Definition: ebase.cpp:25
int getRequested() const
Definition: ebase.h:177
int getFD() const
Definition: ebase.h:176
static eSocketNotifier * create(eMainloop *context, int fd, int req, bool startnow=true)
Constructs a eSocketNotifier.
Definition: ebase.h:167
void setRequested(int req)
Definition: ebase.h:178
~eSocketNotifier()
Definition: ebase.cpp:20
void stop()
Definition: ebase.cpp:37
bool isRunning() const
Definition: ebase.h:174
PSignal1< void, int > activated
Definition: ebase.h:170
eSmartPtrList< iObject > m_clients
Definition: ebase.h:181
Gives a callback after a specified timeout.
Definition: ebase.h:277
void start(long msec, bool b=false)
Definition: ebase.cpp:48
void changeInterval(long msek)
Definition: ebase.cpp:93
bool needsActivation()
Definition: ebase.h:305
bool isActive()
Definition: ebase.h:301
timespec & getNextActivation()
Definition: ebase.h:303
~eTimer()
Definition: ebase.h:297
void stop()
Definition: ebase.cpp:84
PSignal0< void > timeout
Definition: ebase.h:299
bool needsActivation(const timespec &now)
Definition: ebase.h:304
bool operator<(const eTimer &t) const
Definition: ebase.h:311
void startLongTimer(int seconds)
Definition: ebase.cpp:66
static eTimer * create(eMainloop *context=eApp)
Constructs a timer.
Definition: ebase.h:296
static long timeout_usec(const timespec &orig)
Definition: ebase.h:128
static timespec & operator+=(timespec &t1, const timespec &t2)
Definition: ebase.h:36
static bool operator<(const timespec &t1, const timespec &t2)
Definition: ebase.h:26
static bool operator<=(const timespec &t1, const timespec &t2)
Definition: ebase.h:31
static timespec operator-=(timespec &t1, const timespec &t2)
Definition: ebase.h:71
static timespec operator-(const timespec &t1, const timespec &t2)
Definition: ebase.h:59
eApplication * eApp
Definition: ebase.cpp:416
static timespec operator+(const timespec &t1, const timespec &t2)
Definition: ebase.h:47
activate
Definition: SystemPlugins/FastChannelChange/plugin.py:14
#define SWIG_PYOBJECT(x)
Definition: swig.h:23