xpcom/base/nsIMessageLoop.idl
author Simon Sapin <simon.sapin@exyr.org>
Mon, 31 Dec 2018 01:01:49 +0100
changeset 452667 91e7ea77c846ae753fb3a28ab81598d2dc7ac865
parent 297231 7a9039d4e93160820da7eb8c1cdd34d2818166cd
permissions -rw-r--r--
Bug 1518045 - Publish selectors 0.21.0 on crates.io. r=emilio This cherry-picks https://github.com/servo/servo/pull/22577, with the relevant lockfile update.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIRunnable;

/**
 * This service allows access to the current thread's Chromium MessageLoop
 * instance, with some extra sugar added.  If you're calling from C++, it may
 * or may not make sense for you to use this interface.  If you're calling from
 * JS, you don't have a choice!
 *
 * Right now, you can only call PostIdleTask(), and the wrath of khuey is
 * stopping you from adding other methods.
 *
 * nsIMessageLoop's contractid is "@mozilla.org/message-loop;1".
 */
[scriptable, uuid(3E8C58E8-E52C-43E0-8E66-669CA788FF5F)]
interface nsIMessageLoop : nsISupports
{
  /**
   * Posts a task to be run when this thread's message loop is idle, or after
   * ensureRunsAfterMS milliseconds have elapsed.  (That is, the task is
   * guaranteed to run /eventually/.)
   *
   * Note that if the event loop is busy, we will hold a reference to the task
   * until ensureRunsAfterMS milliseconds have elapsed.  Be careful when
   * specifying long timeouts and tasks which hold references to windows or
   * other large objects, because you can leak memory in a difficult-to-detect
   * way!
   */
  void postIdleTask(in nsIRunnable task, in uint32_t ensureRunsAfterMS);
};