timeline: Process events in batches
A batch size of 5 doesn't seem to impact the mainloop any more than a batch of size 1, but it reduces the amount of time spinning the loop quite considerably.
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <libedataserver/libedataserver.h>
|
||||
|
||||
#define BATCH_SIZE 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADD_EVENT,
|
||||
@@ -581,15 +583,21 @@ timeline_source_dispatch (GSource *source,
|
||||
{
|
||||
TimelineSource *timeline_source;
|
||||
GcalTimeline *self;
|
||||
gint processed_events;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
processed_events = 0;
|
||||
timeline_source = (TimelineSource*) source;
|
||||
self = timeline_source->timeline;
|
||||
|
||||
while (processed_events < BATCH_SIZE && !g_queue_is_empty (self->event_queue))
|
||||
{
|
||||
GcalRange *event_range;
|
||||
QueueData *queue_data;
|
||||
GcalEvent *event;
|
||||
gint i;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
timeline_source = (TimelineSource*) source;
|
||||
self = timeline_source->timeline;
|
||||
queue_data = g_queue_pop_head (self->event_queue);
|
||||
|
||||
event = queue_data->event;
|
||||
@@ -663,6 +671,9 @@ timeline_source_dispatch (GSource *source,
|
||||
|
||||
queue_data_free (queue_data);
|
||||
|
||||
processed_events++;
|
||||
}
|
||||
|
||||
GCAL_RETURN (G_SOURCE_CONTINUE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user