| 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 |  | 
|---|
| 16 |  | 
|---|
| 17 | #ifndef Foundation_ActiveStarter_INCLUDED | 
|---|
| 18 | #define Foundation_ActiveStarter_INCLUDED | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | #include "Poco/Foundation.h" | 
|---|
| 22 | #include "Poco/ThreadPool.h" | 
|---|
| 23 | #include "Poco/ActiveRunnable.h" | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 | namespace Poco { | 
|---|
| 27 |  | 
|---|
| 28 |  | 
|---|
| 29 | template <class OwnerType> | 
|---|
| 30 | class ActiveStarter | 
|---|
| 31 | /// The default implementation of the StarterType | 
|---|
| 32 | /// policy for ActiveMethod. It starts the method | 
|---|
| 33 | /// in its own thread, obtained from the default | 
|---|
| 34 | /// thread pool. | 
|---|
| 35 | { | 
|---|
| 36 | public: | 
|---|
| 37 | static void start(OwnerType* /*pOwner*/, ActiveRunnableBase::Ptr pRunnable) | 
|---|
| 38 | { | 
|---|
| 39 | ThreadPool::defaultPool().start(*pRunnable); | 
|---|
| 40 | pRunnable->duplicate(); // The runnable will release itself. | 
|---|
| 41 | } | 
|---|
| 42 | }; | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | } // namespace Poco | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | #endif // Foundation_ActiveStarter_INCLUDED | 
|---|
| 49 |  | 
|---|