~ubuntu-branches/debian/sid/glusterfs/sid

« back to all changes in this revision

Viewing changes to contrib/qemu/qemu-coroutine-sleep.c

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2014-04-22 10:00:41 UTC
  • mfrom: (1.3.25)
  • Revision ID: package-import@ubuntu.com-20140422100041-6mur2ttyvb8zzpfq
Tags: 3.5.0-1
* New upstream release.
  - Rewrite patch 01-spelling-error.
  - Adjust lintian overrides.
  - Install new files.
  - The offical tarball is not properly generated, hack it around.
  - Add symlink from fusermount-glusterfs manpage to mount.glusterfs.
  - Move gsync-sync-gfid from /usr/share to /usr/lib.
  - Add benchmarking directory.
* Remove old versioned build dependencies and build depend on libglib2.0-dev.
* Add lintian override for possible-gpl-code-linked-with-openssl. It is the
  same false positive like with the gluster-server package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * QEMU coroutine sleep
 
3
 *
 
4
 * Copyright IBM, Corp. 2011
 
5
 *
 
6
 * Authors:
 
7
 *  Stefan Hajnoczi    <stefanha@linux.vnet.ibm.com>
 
8
 *
 
9
 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
 
10
 * See the COPYING.LIB file in the top-level directory.
 
11
 *
 
12
 */
 
13
 
 
14
#include "block/coroutine.h"
 
15
#include "qemu/timer.h"
 
16
 
 
17
typedef struct CoSleepCB {
 
18
    QEMUTimer *ts;
 
19
    Coroutine *co;
 
20
} CoSleepCB;
 
21
 
 
22
static void co_sleep_cb(void *opaque)
 
23
{
 
24
    CoSleepCB *sleep_cb = opaque;
 
25
 
 
26
    qemu_coroutine_enter(sleep_cb->co, NULL);
 
27
}
 
28
 
 
29
void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns)
 
30
{
 
31
    CoSleepCB sleep_cb = {
 
32
        .co = qemu_coroutine_self(),
 
33
    };
 
34
    sleep_cb.ts = qemu_new_timer(clock, SCALE_NS, co_sleep_cb, &sleep_cb);
 
35
    qemu_mod_timer(sleep_cb.ts, qemu_get_clock_ns(clock) + ns);
 
36
    qemu_coroutine_yield();
 
37
    qemu_del_timer(sleep_cb.ts);
 
38
    qemu_free_timer(sleep_cb.ts);
 
39
}