~ubuntu-branches/ubuntu/karmic/glib2.0/karmic-updates

« back to all changes in this revision

Viewing changes to gio/gioscheduler.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-07 08:55:47 UTC
  • mfrom: (1.2.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20090707085547-oma0yur1uaq4zmop
Tags: 2.21.3-0ubuntu1
* New upstream version:
  - GMappedFile is refcounted now
  - Mainloop: It is now possible to set per-thread default contexts,
    with g_main_context_push_thread_default.
  - glib-mkenums supports a @basename@ substitution, in addition
    to @filename@.
  - GIO:
    + Vfs implementations can support storing of per-file metadata.
    + GCancellable can now be subclassed.
    + Unmount and eject methods now optionally allow interaction, via
      variants that take a GMountOperation object.
  - Bugs fixed:
   556706 Inconsistent help arguments -h, -?
   579449 FileChoosers no longer work if an idle handler is active
   579933 mainloop FD_CLOEXEC has a race condition
   579984 alternate GMainContext support
   585937 gio/gsocket.c (glib 2.21.2) does not compile (Windows/mingw)
   586675 Runtime library location
   586797 Add GCancellables to GSocket ops
   586868 g_filename_complete_get_completions doesn't always return...
   587415 g_resolver_lookup_by_name_finish returns a freed list
   587434 regression tests fail, at least on x86_64
   586928 Avoid g++ warning in g_error()
  - Updated translations: Estonian, Hebrew
* Drop 00git_file_attr_stringv.patch, in upstream release now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
  gint io_priority;
57
57
  GCancellable *cancellable;
 
58
  GMainContext *context;
58
59
 
59
60
  guint idle_tag;
60
61
};
72
73
{
73
74
  if (job->cancellable)
74
75
    g_object_unref (job->cancellable);
 
76
  if (job->context)
 
77
    g_main_context_unref (job->context);
75
78
  g_free (job);
76
79
}
77
80
 
242
245
  if (cancellable)
243
246
    job->cancellable = g_object_ref (cancellable);
244
247
 
 
248
  job->context = g_main_context_get_thread_default ();
 
249
  if (job->context)
 
250
    g_main_context_ref (job->context);
 
251
 
245
252
  G_LOCK (active_jobs);
246
253
  active_jobs = g_slist_prepend (active_jobs, job);
247
254
  job->active_link = active_jobs;
257
264
      /* Threads not available, instead do the i/o sync inside a
258
265
       * low prio idle handler
259
266
       */
260
 
      job->idle_tag = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE + 1 + io_priority / 10,
 
267
      job->idle_tag = g_idle_add_full (io_priority,
261
268
                                       run_job_at_idle,
262
269
                                       job, job_destroy);
263
270
    }
341
348
/**
342
349
 * g_io_scheduler_job_send_to_mainloop:
343
350
 * @job: a #GIOSchedulerJob
344
 
 * @func: a #GSourceFunc callback that will be called in the main thread
 
351
 * @func: a #GSourceFunc callback that will be called in the original thread
345
352
 * @user_data: data to pass to @func
346
353
 * @notify: a #GDestroyNotify for @user_data, or %NULL
347
354
 * 
348
 
 * Used from an I/O job to send a callback to be run in the 
349
 
 * main loop (main thread), waiting for the result (and thus 
 
355
 * Used from an I/O job to send a callback to be run in the thread
 
356
 * that the job was started from, waiting for the result (and thus
350
357
 * blocking the I/O job).
351
358
 *
352
359
 * Returns: The return value of @func
359
366
{
360
367
  GSource *source;
361
368
  MainLoopProxy *proxy;
362
 
  guint id;
363
369
  gboolean ret_val;
364
370
 
365
371
  g_return_val_if_fail (job != NULL, FALSE);
389
395
  g_source_set_callback (source, mainloop_proxy_func, proxy,
390
396
                         NULL);
391
397
 
392
 
  id = g_source_attach (source, NULL);
 
398
  g_source_attach (source, job->context);
393
399
  g_source_unref (source);
394
400
 
395
401
  g_cond_wait (proxy->ack_condition, proxy->ack_lock);
404
410
/**
405
411
 * g_io_scheduler_job_send_to_mainloop_async:
406
412
 * @job: a #GIOSchedulerJob
407
 
 * @func: a #GSourceFunc callback that will be called in the main thread
 
413
 * @func: a #GSourceFunc callback that will be called in the original thread
408
414
 * @user_data: data to pass to @func
409
415
 * @notify: a #GDestroyNotify for @user_data, or %NULL
410
416
 * 
411
 
 * Used from an I/O job to send a callback to be run asynchronously 
412
 
 * in the main loop (main thread). The callback will be run when the 
413
 
 * main loop is available, but at that time the I/O job might have 
414
 
 * finished. The return value from the callback is ignored.
 
417
 * Used from an I/O job to send a callback to be run asynchronously in
 
418
 * the thread that the job was started from. The callback will be run
 
419
 * when the main loop is available, but at that time the I/O job might
 
420
 * have finished. The return value from the callback is ignored.
415
421
 *
416
422
 * Note that if you are passing the @user_data from g_io_scheduler_push_job()
417
423
 * on to this function you have to ensure that it is not freed before
426
432
{
427
433
  GSource *source;
428
434
  MainLoopProxy *proxy;
429
 
  guint id;
430
435
 
431
436
  g_return_if_fail (job != NULL);
432
437
  g_return_if_fail (func != NULL);
452
457
  g_source_set_callback (source, mainloop_proxy_func, proxy,
453
458
                         (GDestroyNotify)mainloop_proxy_free);
454
459
 
455
 
  id = g_source_attach (source, NULL);
 
460
  g_source_attach (source, job->context);
456
461
  g_source_unref (source);
457
462
}
458
463