Home > Net >  How to provide `Context` to async functions
How to provide `Context` to async functions

Time:01-02

I am trying call the poll_flush method, which requires a Context object. I wonder how to obtain such object in tokio runtime?

CodePudding user response:

You don't call poll_* methods yourself unless you're writing a runtime, let the runtime do it for you using await on the corresponding async functions. Instead of calling poll_flush you should be calling AsyncWriteExt::flush().await.

  • Related