ActiveStarter.h 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // ActiveStarter.h
  3. //
  4. // Library: Foundation
  5. // Package: Threading
  6. // Module: ActiveObjects
  7. //
  8. // Definition of the ActiveStarter class.
  9. //
  10. // Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_ActiveStarter_INCLUDED
  16. #define Foundation_ActiveStarter_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include "Poco/ThreadPool.h"
  19. #include "Poco/ActiveRunnable.h"
  20. namespace Poco {
  21. template <class OwnerType>
  22. class ActiveStarter
  23. /// The default implementation of the StarterType
  24. /// policy for ActiveMethod. It starts the method
  25. /// in its own thread, obtained from the default
  26. /// thread pool.
  27. {
  28. public:
  29. static void start(OwnerType* /*pOwner*/, ActiveRunnableBase::Ptr pRunnable)
  30. {
  31. ThreadPool::defaultPool().start(*pRunnable);
  32. pRunnable->duplicate(); // The runnable will release itself.
  33. }
  34. };
  35. } // namespace Poco
  36. #endif // Foundation_ActiveStarter_INCLUDED