coth.c 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * 9p backend
  3. *
  4. * Copyright IBM, Corp. 2010
  5. *
  6. * Authors:
  7. * Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
  8. * Venkateswararao Jujjuri(JV) <jvrao@linux.vnet.ibm.com>
  9. *
  10. * This work is licensed under the terms of the GNU GPL, version 2. See
  11. * the COPYING file in the top-level directory.
  12. *
  13. */
  14. #include "qemu/osdep.h"
  15. #include "block/thread-pool.h"
  16. #include "qemu/coroutine.h"
  17. #include "qemu/main-loop.h"
  18. #include "coth.h"
  19. /* Called from QEMU I/O thread. */
  20. static void coroutine_enter_cb(void *opaque, int ret)
  21. {
  22. Coroutine *co = opaque;
  23. qemu_coroutine_enter(co);
  24. }
  25. /* Called from worker thread. */
  26. static int coroutine_enter_func(void *arg)
  27. {
  28. Coroutine *co = arg;
  29. qemu_coroutine_enter(co);
  30. return 0;
  31. }
  32. void co_run_in_worker_bh(void *opaque)
  33. {
  34. Coroutine *co = opaque;
  35. thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
  36. coroutine_enter_func, co, coroutine_enter_cb, co);
  37. }