# @async calls to C API yields?

**URL:** https://discourse.julialang.org/t/async-calls-to-c-api-yields/15399
**Category:** General Usage
**Tags:** question
**Created:** [September 23, 2018, 9:37pm UTC](https://discourse.julialang.org/t/async-calls-to-c-api-yields/15399 "2018-09-23T21:37:55Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [September 24, 2018, 3:00am UTC](https://discourse.julialang.org/t/async-calls-to-c-api-yields/15399/3 "2018-09-24T03:00:03Z")

</div>

> [@stevengj](#):
>
> call the Julia `yield()` function

But then I don’t think you can do the IO while calling `yield`? I suppose all the IO has to go through the event loop in order to do them concurrently (non-blockingly).

IIUC, if you need to do IO without touching libuv’s IO interface, then you have to do it in a different thread. To ping Julia to come back to the C function in the main thread, you call `uv_async_send(cond.handle)` from the IO thread once the IO is finished, where this `cond` is created with [`Base.AsyncCondition`](https://docs.julialang.org/en/v1/base/base/#Base.AsyncCondition). You can call Julia code `wait(cond)` in the thread that initialized Julia. During this `wait(cond)`, Julia can run other tasks and block until `uv_async_send`. (Not sure if this is the only solution. It’s just what I know.)

---

_[View the full topic](https://discourse.julialang.org/t/async-calls-to-c-api-yields/15399)._
