summaryrefslogtreecommitdiff
path: root/tumblerd/tumbler-group-scheduler.c
blob: 080213ba5879e13be5e2d8f6e6af922e0061765a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
 * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
 * Copyright (c) 2009 Nokia,
 *   written by Philip Van Hoof <philip@codeminded.be>
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <float.h>

#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>

#include <tumbler/tumbler.h>

#include <tumblerd/tumbler-group-scheduler.h>
#include <tumblerd/tumbler-scheduler.h>
#include <tumblerd/tumbler-utils.h>



/* Property identifiers */
enum
{
  PROP_0,
  PROP_NAME,
};



typedef struct _UriError UriError;



static void tumbler_group_scheduler_iface_init        (TumblerSchedulerIface     *iface);
static void tumbler_group_scheduler_finalize          (GObject                   *object);
static void tumbler_group_scheduler_get_property      (GObject                   *object,
                                                       guint                      prop_id,
                                                       GValue                    *value,
                                                       GParamSpec                *pspec);
static void tumbler_group_scheduler_set_property      (GObject                   *object,
                                                       guint                      prop_id,
                                                       const GValue              *value,
                                                       GParamSpec                *pspec);
static void tumbler_group_scheduler_push              (TumblerScheduler          *scheduler,
                                                       TumblerSchedulerRequest   *request);
static void tumbler_group_scheduler_dequeue           (TumblerScheduler          *scheduler,
                                                       guint32                    handle);
static void tumbler_group_scheduler_cancel_by_mount   (TumblerScheduler          *scheduler,
                                                       GMount                    *mount);
static void tumbler_group_scheduler_finish_request    (TumblerGroupScheduler     *scheduler,
                                                       TumblerSchedulerRequest   *request);
static void tumbler_group_scheduler_dequeue_request   (TumblerSchedulerRequest   *request,
                                                       gpointer                   user_data);
static void tumbler_group_scheduler_thread            (gpointer                   data,
                                                       gpointer                   user_data);
static void tumbler_group_scheduler_thumbnailer_error (TumblerThumbnailer        *thumbnailer,
                                                       const gchar               *failed_uri,
                                                       GQuark                     error_domain,
                                                       gint                       error_code,
                                                       const gchar               *message,
                                                       GList                    **uri_errors);
static void tumbler_group_scheduler_thumbnailer_ready (TumblerThumbnailer        *thumbnailer,
                                                       const gchar               *uri,
                                                       GList                    **ready_uris);



struct _TumblerGroupSchedulerClass
{
  GObjectClass __parent__;
};

struct _TumblerGroupScheduler
{
  GObject __parent__;

  GThreadPool *pool;
  TUMBLER_MUTEX (mutex);
  GList       *requests;
  guint        group;
  gboolean     prioritized;

  gchar       *name;
};

struct _UriError
{
  guint  error_code;
  GQuark error_domain;
  gchar *message;
  gchar *failed_uri;
};




G_LOCK_DEFINE (group_access_lock);



G_DEFINE_TYPE_WITH_CODE (TumblerGroupScheduler,
                         tumbler_group_scheduler,
                         G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (TUMBLER_TYPE_SCHEDULER,
                                                tumbler_group_scheduler_iface_init));



static void
tumbler_group_scheduler_class_init (TumblerGroupSchedulerClass *klass)
{
  GObjectClass *gobject_class;

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->finalize = tumbler_group_scheduler_finalize; 
  gobject_class->get_property = tumbler_group_scheduler_get_property;
  gobject_class->set_property = tumbler_group_scheduler_set_property;

  g_object_class_override_property (gobject_class, PROP_NAME, "name");

}


static void
tumbler_group_scheduler_iface_init (TumblerSchedulerIface *iface)
{
  iface->push = tumbler_group_scheduler_push;
  iface->dequeue = tumbler_group_scheduler_dequeue;
  iface->cancel_by_mount = tumbler_group_scheduler_cancel_by_mount;
}



static void
tumbler_group_scheduler_init (TumblerGroupScheduler *scheduler)
{
  tumbler_mutex_create (scheduler->mutex);
  scheduler->requests = NULL;

  /* Note that unless we convert this boolean to a TLS (thread-local), that
   * we can only do this 'prioritized' flag with a thread-pool that is set to
   * exclusive: because then the one thread keeps running until the pool is 
   * freed. */

  scheduler->prioritized = FALSE;

  /* allocate a pool with one thread for all requests */
  scheduler->pool = g_thread_pool_new (tumbler_group_scheduler_thread, 
                                       scheduler, 1, TRUE, NULL);

}



static void
tumbler_group_scheduler_finalize (GObject *object)
{
  TumblerGroupScheduler *scheduler = TUMBLER_GROUP_SCHEDULER (object);

  /* destroy both thread pools */
  g_thread_pool_free (scheduler->pool, TRUE, TRUE);

  /* release all pending requests and destroy the request list */
  g_list_free_full (scheduler->requests, tumbler_scheduler_request_free);

  /* free the scheduler name */
  g_free (scheduler->name);

  /* destroy the mutex */
  tumbler_mutex_free (scheduler->mutex);

  (*G_OBJECT_CLASS (tumbler_group_scheduler_parent_class)->finalize) (object);
}



static void
tumbler_group_scheduler_get_property (GObject    *object,
                                      guint       prop_id,
                                      GValue     *value,
                                      GParamSpec *pspec)
{
  TumblerGroupScheduler *scheduler = TUMBLER_GROUP_SCHEDULER (object);

  switch (prop_id)
    {
    case PROP_NAME:
      g_value_set_string (value, scheduler->name);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}



static void
tumbler_group_scheduler_set_property (GObject      *object,
                                      guint         prop_id,
                                      const GValue *value,
                                      GParamSpec   *pspec)
{
  TumblerGroupScheduler *scheduler = TUMBLER_GROUP_SCHEDULER (object);

  switch (prop_id)
    {
    case PROP_NAME:
      scheduler->name = g_value_dup_string (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}



static void
tumbler_group_scheduler_push (TumblerScheduler        *scheduler,
                              TumblerSchedulerRequest *request)
{
  TumblerGroupScheduler *group_scheduler = 
    TUMBLER_GROUP_SCHEDULER (scheduler);

  g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler));
  g_return_if_fail (request != NULL);

  tumbler_mutex_lock (group_scheduler->mutex);
  
  /* gain ownership over the requests (sets request->scheduler) */
  tumbler_scheduler_take_request (scheduler, request);

  /* prepend the request to the request list */
  group_scheduler->requests = g_list_prepend (group_scheduler->requests, request);

  /* enqueue the request in the pool */
  g_thread_pool_push (group_scheduler->pool, request, NULL);

  tumbler_mutex_unlock (group_scheduler->mutex);
}



static void
tumbler_group_scheduler_dequeue (TumblerScheduler *scheduler,
                                 guint32           handle)
{
  TumblerGroupScheduler *group_scheduler = 
    TUMBLER_GROUP_SCHEDULER (scheduler);

  g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler));
  g_return_if_fail (handle != 0);

  tumbler_mutex_lock (group_scheduler->mutex);

  /* dequeue all requests (usually only one) with this handle */
  g_list_foreach (group_scheduler->requests, 
                  (GFunc) tumbler_group_scheduler_dequeue_request, 
                  GUINT_TO_POINTER (handle));

  tumbler_mutex_unlock (group_scheduler->mutex);
}



static void
tumbler_group_scheduler_cancel_by_mount (TumblerScheduler *scheduler,
                                        GMount           *mount)
{
  TumblerSchedulerRequest *request;
  TumblerGroupScheduler   *group_scheduler = TUMBLER_GROUP_SCHEDULER (scheduler);
  GFile                   *mount_point;
  GFile                   *file;
  GList                   *iter;
  guint                    n;

  g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler));
  g_return_if_fail (G_IS_MOUNT (mount));

  /* determine the root mount point */
  mount_point = g_mount_get_root (mount);

  tumbler_mutex_lock (group_scheduler->mutex);

  /* iterate over all requests */
  for (iter = group_scheduler->requests; iter != NULL; iter = iter->next)
    {
      request = iter->data;

      /* iterate over all request URIs */
      for (n = 0; n < request->length; ++n)
        {
          /* determine the enclosing mount for the file */
          file = g_file_new_for_uri (tumbler_file_info_get_uri (request->infos[n]));

          /* cancel the URI if it lies of the mount point */
          if (g_file_has_prefix (file, mount_point))
            g_cancellable_cancel (request->cancellables[n]);

          /* release the file object */
          g_object_unref (file);
        }
    }

  tumbler_mutex_unlock (group_scheduler->mutex);

  /* release the mount point */
  g_object_unref (mount_point);
}



static void
tumbler_group_scheduler_finish_request (TumblerGroupScheduler *scheduler,
                                        TumblerSchedulerRequest   *request)
{
  g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler));
  g_return_if_fail (request != NULL);

  /* emit a  signal */
  g_signal_emit_by_name (scheduler, "finished", request->handle, request->origin);

  /* remove the request from the request list */
  scheduler->requests = g_list_remove (scheduler->requests, request);

  /* destroy the request */
  tumbler_scheduler_request_free (request);
}



static void
tumbler_group_scheduler_dequeue_request (TumblerSchedulerRequest *request,
                                         gpointer                 user_data)
{
  guint handle = GPOINTER_TO_UINT (user_data);
  guint n;

  g_return_if_fail (request != NULL);
  g_return_if_fail (handle != 0);

  /* mark the request as dequeued if the handles match */
  if (request->handle == handle) 
    {
      request->dequeued = TRUE;

      /* try cancel all thumbnails that are part of the request */
      for (n = 0; n < request->length; ++n)
        g_cancellable_cancel (request->cancellables[n]);
  }
}



static UriError *
uri_error_new (gint         code,
               GQuark       domain,
               const gchar *uri,
               const gchar *message)
{
  UriError *error;

  error = g_slice_new0 (UriError);
  error->error_domain = domain;
  error->error_code = code;
  error->failed_uri = g_strdup (uri);
  error->message = g_strdup (message);

  return error;
}



static void
uri_error_free (gpointer data)
{
  UriError *error = data;

  g_free (error->message);
  g_free (error->failed_uri);

  g_slice_free (UriError, error);
}



static void
tumbler_group_scheduler_thread (gpointer data,
                                gpointer user_data)
{
  TumblerSchedulerRequest *request = data;
  TumblerGroupScheduler   *scheduler = user_data;
  const gchar            **uris;
  const gchar            **failed_uris;
  const gchar            **success_uris;
  UriError                *uri_error;
  gboolean                 uri_needs_update;
  GString                 *message;
  GError                  *error = NULL;
  GList                   *iter;
  GList                   *uri_errors;
  GList                   *ready_uris;
  GList                   *cached_uris = NULL;
  GList                   *missing_uris = NULL;
  GList                   *lp, *lq;
  guint                    n;
  gint                     error_code = 0;
  GQuark                   error_domain = 0;

  g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler));
  g_return_if_fail (request != NULL);

  /* Set I/O priority for the exclusive ThreadPool's thread */
  if (!scheduler->prioritized) 
    {
      tumbler_scheduler_thread_use_lower_priority ();
      scheduler->prioritized = TRUE;
    }

  /* notify others that we're starting to process this request */
  g_signal_emit_by_name (request->scheduler, "started", request->handle, 
                         request->origin);

  /* finish the request if it was dequeued */
  tumbler_mutex_lock (scheduler->mutex);
  if (request->dequeued)
    {
      tumbler_group_scheduler_finish_request (scheduler, request);
      tumbler_mutex_unlock (scheduler->mutex);
      return;
    }
  tumbler_mutex_unlock (scheduler->mutex);

  /* process URI by URI */
  for (n = 0; n < request->length; ++n)
    {
      /* finish the request if it was dequeued */
      tumbler_mutex_lock (scheduler->mutex);
      if (request->dequeued)
        {
          tumbler_group_scheduler_finish_request (scheduler, request);
          tumbler_mutex_unlock (scheduler->mutex);
          return;
        }
      tumbler_mutex_unlock (scheduler->mutex);

      /* ignore the the URI if has been cancelled already */
      if (g_cancellable_is_cancelled (request->cancellables[n]))
        continue;

      /* create a file infor for the current URI */
      uri_needs_update = FALSE;

      G_LOCK (group_access_lock);

      /* try to load thumbnail information about the URI */
      if (tumbler_file_info_load (request->infos[n], NULL, &error))
        {
          /* check if we have a thumbnailer for the URI */
          if (request->thumbnailers[n] != NULL)
            {
              /* check if the thumbnail needs an update */
              uri_needs_update = tumbler_file_info_needs_update (request->infos[n]);
            }
          else
            {
              /* no thumbnailer for this URI, we need to emit an error */
              g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_UNSUPPORTED,
                           TUMBLER_ERROR_MESSAGE_NO_THUMBNAILER,
                           tumbler_file_info_get_uri (request->infos[n]));
            }
        }

      G_UNLOCK (group_access_lock);

      /* check if the URI is supported */
      if (error == NULL)
        {
          /* put it in the right list depending on its thumbnail status */
          if (uri_needs_update)
            missing_uris = g_list_prepend (missing_uris, GINT_TO_POINTER (n));
          else
            cached_uris = g_list_prepend (cached_uris, request->infos[n]);
        }
      else
        {
          /* emit an error for the URI */
          tumbler_scheduler_emit_uri_error (TUMBLER_SCHEDULER (scheduler), request,
                                            tumbler_file_info_get_uri (request->infos[n]),
                                            error);
          g_clear_error (&error);
        }
    }

  /* check if we have any cached files */
  if (cached_uris != NULL)
    {
      /* allocate a URI array and fill it with all cached URIs */
      uris = g_new0 (const gchar *, g_list_length (cached_uris) + 1);
      for (n = 0, lp = g_list_last (cached_uris); lp != NULL; lp = lp->prev, ++n)
        uris[n] = tumbler_file_info_get_uri (lp->data);
      uris[n] = NULL;

      /* notify others that the cached thumbnails are ready */
      g_signal_emit_by_name (scheduler, "ready", request->handle, uris, 
                             request->origin);

      /* free string array and cached list */
      g_list_free (cached_uris);
      g_free (uris);
    }

  /* initialize lists for grouping failed URIs and URIs for which 
   * thumbnails are ready */
  uri_errors = NULL;
  ready_uris = NULL;

  /* iterate over invalid/missing URI list */
  for (lp = g_list_last (missing_uris); lp != NULL; lp = lp->prev)
    {
      n = GPOINTER_TO_INT (lp->data);

      /* finish the request if it was dequeued */
      tumbler_mutex_lock (scheduler->mutex);
      if (request->dequeued)
        {
          tumbler_group_scheduler_finish_request (scheduler, request);
          tumbler_mutex_unlock (scheduler->mutex);
          return;
        }
      tumbler_mutex_unlock (scheduler->mutex);

      for (lq = request->thumbnailers[n]; lq != NULL; lq = lq->next)
        {
          /* forward only the error signal of the last thumbnailer */
          if (lq->next == NULL)
            g_signal_connect (lq->data, "error",
                              G_CALLBACK (tumbler_group_scheduler_thumbnailer_error), &uri_errors);
          else if (tumbler_util_is_debug_logging_enabled (G_LOG_DOMAIN))
            g_signal_connect (lq->data, "error",
                              G_CALLBACK (tumbler_scheduler_thumberr_debuglog), request);

          /* connect to the ready signal of the thumbnailer */
          g_signal_connect (lq->data, "ready",
                            G_CALLBACK (tumbler_group_scheduler_thumbnailer_ready), &ready_uris);

          /* cancel lower priority thumbnailers for this uri on ready signal */
          g_signal_connect_swapped (lq->data, "ready", G_CALLBACK (g_cancellable_cancel),
                                    request->cancellables[n]);

          /* tell the thumbnailer to generate the thumbnail */
          tumbler_thumbnailer_create (lq->data, request->cancellables[n], request->infos[n]);

          /* disconnect from all signals when we're finished */
          g_signal_handlers_disconnect_by_data (lq->data, &uri_errors);
          g_signal_handlers_disconnect_by_data (lq->data, &ready_uris);
          g_signal_handlers_disconnect_by_data (lq->data, request);
          g_signal_handlers_disconnect_by_data (lq->data, request->cancellables[n]);
        }
    }

  tumbler_mutex_lock (scheduler->mutex);

  /* We emit all the errors and ready signals together in order to 
   * reduce the overall D-Bus traffic */

  /* check if we have any failed URIs */
  if (uri_errors != NULL)
    {
      /* allocate the failed URIs array */
      failed_uris = g_new0 (const gchar *, g_list_length (uri_errors) + 1);

      /* allocate the grouped error message */
      message = g_string_new ("");

      for (iter = uri_errors, n = 0; iter != NULL; iter = iter->next, ++n) 
        {
          uri_error = iter->data;

          /* we use the error code of the first failed URI */
          if (iter == uri_errors)
            {
              error_domain = uri_error->error_domain;
              error_code = uri_error->error_code;
            }

          if (uri_error->message != NULL)
            {
              /* we concatenate error messages with a newline inbetween */
              if (iter != uri_errors && iter->next != NULL)
                g_string_append_c (message, '\n');

              /* append the current error message */
              g_string_append (message, uri_error->message);
            }

          /* fill the failed_uris array with URIs */
          failed_uris[n] = uri_error->failed_uri;
        }

      /* NULL-terminate the failed URI array */
      failed_uris[n] = NULL;

      /* forward the error signal */
      g_signal_emit_by_name (request->scheduler, "error", request->handle, 
                             failed_uris, error_domain, error_code, message->str,
                             request->origin);

      /* free the failed URIs array. Its contents are owned by the URI errors */
      g_free (failed_uris);

      /* free the error message */
      g_string_free (message, TRUE);
    }

  /* free all URI errors and the error URI list */
  g_list_free_full (uri_errors, uri_error_free);

  /* check if we have any successfully processed URIs */
  if (ready_uris != NULL)
    {
      /* allocate a string array for successful URIs */
      success_uris = g_new0 (const gchar *, g_list_length (ready_uris) + 1);

      /* fill the array with all ready URIs */
      for (iter = ready_uris, n = 0; iter != NULL; iter = iter->next, ++n)
        success_uris[n] = iter->data;

      /* NULL-terminate the successful URI array */
      success_uris[n] = NULL;

      /* emit a grouped ready signal */
      g_signal_emit_by_name (request->scheduler, "ready", request->handle, 
                             success_uris, request->origin);

      /* free the success URI array. Its contents are owned by the ready URI list */
      g_free (success_uris);
    }

  /* free the ready URIs */
  g_list_free_full (ready_uris, g_free);

  /* notify others that we're finished processing the request */
  tumbler_group_scheduler_finish_request (scheduler, request);

  tumbler_mutex_unlock (scheduler->mutex);
}



static void
tumbler_group_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer,
                                           const gchar        *failed_uri,
                                           GQuark              error_domain,
                                           gint                error_code,
                                           const gchar        *message,
                                           GList             **uri_errors)
{
  UriError *error;

  g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
  g_return_if_fail (failed_uri != NULL);
  g_return_if_fail (uri_errors != NULL);

  /* allocate a new URI error */
  error = uri_error_new (error_code, error_domain, failed_uri, message);

  /* add the error to the list */
  *uri_errors = g_list_prepend (*uri_errors, error);
}



static void
tumbler_group_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnailer,
                                           const gchar        *uri,
                                           GList             **ready_uris)
{
  g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
  g_return_if_fail (uri != NULL);
  g_return_if_fail (ready_uris != NULL);

  *ready_uris = g_list_prepend (*ready_uris, g_strdup (uri));
}



TumblerScheduler *
tumbler_group_scheduler_new (const gchar *name)
{
  return g_object_new (TUMBLER_TYPE_GROUP_SCHEDULER, "name", name, NULL);
}