Make the macro return the appropriate pointer type, and make sure the
free function takes an argument of the same type. This also eliminates
some boilerplate type-casting code.
Change-Id: I3094271fa2c53ec93b9ff9f837d461cf422e0f12
Look up the first object in the tree to determine the needed sleep time.
But instead of leaving the object in the tree for the next (post-sleep)
iteration, which requires another tree lookup, remove it from the tree
and remember it, anticipating that nothing would get added into the tree
to be scheduled sooner. This saves us from having to do another tree
lookup for each timer that runs.
Adapt the scheduling function to be able to handle this and wake up the
thread sooner if necessary.
Change-Id: I9297346bc4aa8d2f68ecb833be8f71ce62a3bbfe
If the timer thread is already scheduled to wake before the timer that
we want to schedule, then there is no need to wake it up for nothing.
Change-Id: I5e6174bb0347954dfc5d012befe31625fad9961a
This should prevent multiple threads from fighting over the same shared
structures (GTree + mutex + condition). Downside is that it may lead to
load not being perfectly balanced between threads.
Change-Id: I8127b98dcfbeafd692d74e60cdf6d60e3e572ba7
In the file implementations follow the rules:
1. Firstly goes the correlated header file, then one empty row.
2. Secondly go system headers, so in angle-brackets, then one empty row.
3. Thirdly, go custom header files, so in double quotes,
then one empty row.
4. If there is "xt_RTPENGINE.h", it's mentioned next, but separately,
then one empty row.
5. If there are pre-processor definitions, they are added.
6. And eventually at least one empty row before the code.
In some situations it's allowed to step aside from the rules,
when inclusions are dependent on each other, so on the sequence,
and also possibly on some inline objects definitions, but if possible
to follow the rules, it's being done.
Change-Id: Ie512a970e230fe202398656d1942e8874bb14cd9
This is useful for functions which are used both from a timer and from
other callers. These functions would reset the logging context at their
end to free the reference held by the logging context, which would
wrongly reset the logging context when the same function was called from
a different code path. Using a stack with push/pop semantics makes it
safe to use these functions from any code path.
Additionally introduce an explicit reset function that clears the entire
stack regardless of context. This reset function is called at the end of
every work iteration in every worker thread, just in case not everything
was popped from the stack.
Change-Id: I0e2c142b95806b26473c65a882737e39d161d24d
The only reason the wait time in timer threads is capped at 100 ms is to
catch the daemon's shutdown. Since these threads already use a
condition variable to be woken up, we can use the same condition to wake
up the threads during a shutdown, allowing for a much longer (possibly
unlimited) sleep time in timer threads.
Change-Id: I3b5f280a4d502176a731e8b52b1b731022c8db4f
When a new timer object is scheduled to run in the future, we only need
to wake up one thread to notify about the new object as only one thread
is needed to handle it. The other threads can remain in the previous
sleep state.
Change-Id: I92ccec61a6c5a4a3cea5c5428c85f83707cf4d64
This makes sure all objects are cleaned up during shutdown even if the
respective timer hasn't run yet.
Change-Id: I197b930f1b6e407819cc5a8c4ebd92fcef21b2cd