AsyncEventRunner.h 795 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef MOZILLA_ASYNCEVENTRUNNER_H_
  6. #define MOZILLA_ASYNCEVENTRUNNER_H_
  7. #include "nsThreadUtils.h"
  8. namespace mozilla {
  9. template <typename T>
  10. class AsyncEventRunner : public Runnable
  11. {
  12. public:
  13. AsyncEventRunner(T* aTarget, const char* aName)
  14. : mTarget(aTarget)
  15. , mName(aName)
  16. {}
  17. NS_IMETHOD Run() override
  18. {
  19. mTarget->DispatchSimpleEvent(mName);
  20. return NS_OK;
  21. }
  22. private:
  23. RefPtr<T> mTarget;
  24. const char* mName;
  25. };
  26. } // namespace mozilla
  27. #endif /* MOZILLA_ASYNCEVENTRUNNER_H_ */