title: How to call a poll_* method?
body: <p>I am trying to implement a cache in Rust using <code>DelayQueue</code> based on an <a href="https://docs.rs/tokio-util/latest/tokio_util/time/struct.DelayQueue.html#usage-1" rel="nofollow noreferrer">this example</a> provided in the <code>tokio_util</code> documentation. This is my code:</p>
  <pre class="lang-toml prettyprint-override"><code># Cargo.toml
  [dependencies]
  futures = &quot;0.3&quot;
  tokio-util = { version = &quot;0.7.3&quot;, features = [&quot;full&quot;] }
  tokio = { version = &quot;1.19.2&quot;, features = [&quot;full&quot;] }
  </code></pre>
  <pre><code>use tokio_util::time::{delay_queue, DelayQueue};
  
  use futures::ready;
  use std::collections::HashMap;
  use std::task::{Context, Poll};
  use std::time::Duration;
  
  type CacheKey = String;
  type Value = String;
  
  struct Cache {
      entries: HashMap&lt;CacheKey, (Value, delay_queue::Key)&gt;,
      expirations: DelayQueue&lt;CacheKey&gt;,
  }
  
  const TTL_SECS: u64 = 10;
  
  impl Cache {
      fn new() -&gt; Cache {
          Cache {
              entries: HashMap::new(),
              expirations: DelayQueue::new(),
          }
      }
  
      fn insert(&amp;mut self, key: CacheKey, value: Value) {
          let delay = self
              .expirations
              .insert(key.clone(), Duration::from_secs(TTL_SECS));
  
          self.entries.insert(key, (value, delay));
      }
  
      fn _get(&amp;self, key: &amp;CacheKey) -&gt; Option&lt;&amp;Value&gt; {
          self.entries.get(key).map(|&amp;(ref v, _)| v)
      }
  
      fn remove(&amp;mut self, key: &amp;CacheKey) {
          if let Some((_, cache_key)) = self.entries.remove(key) {
              self.expirations.remove(&amp;cache_key);
          }
      }
  
      fn poll_purge(&amp;mut self, cx: &amp;mut Context&lt;'_&gt;) -&gt; Poll&lt;()&gt; {
          while let Some(entry) = ready!(self.expirations.poll_expired(cx)) {
              self.entries.remove(entry.get_ref());
          }
  
          Poll::Ready(())
      }
  }
  
  #[tokio::main]
  async fn main() {
      let mut cache = Cache::new();
      cache.insert(&quot;k1&quot;.to_string(), &quot;v1&quot;.to_string());
      cache.insert(&quot;k2&quot;.to_string(), &quot;v2&quot;.to_string());
      cache.insert(&quot;k3&quot;.to_string(), &quot;v3&quot;.to_string());
      cache.insert(&quot;k4&quot;.to_string(), &quot;v4&quot;.to_string());
      cache.insert(&quot;k5&quot;.to_string(), &quot;v5&quot;.to_string());
  
      // code for consuming from the queue
  }
  </code></pre>
  <p>I want to call <code>poll_purge()</code> method on my <code>cache</code> object but it has a parameter that I don't know what to pass:</p>
  <pre><code>cx: &amp;mut Context&lt;'_&gt;
  </code></pre>
  <p>How should I change my code?</p>