mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-15 07:14:46 +02:00
integrated latest changes from main rep
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveDispatcher.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveDispatcher.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveDispatcher.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ActiveDispatcher class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "Poco/Runnable.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/ActiveStarter.h"
|
||||
#include "Poco/ActiveRunnable.h"
|
||||
#include "Poco/NotificationQueue.h"
|
||||
|
||||
|
||||
@@ -102,7 +103,7 @@ public:
|
||||
virtual ~ActiveDispatcher();
|
||||
/// Destroys the ActiveDispatcher.
|
||||
|
||||
void start(Runnable* pRunnable);
|
||||
void start(ActiveRunnableBase::Ptr pRunnable);
|
||||
/// Adds the Runnable to the dispatch queue.
|
||||
|
||||
void cancel();
|
||||
@@ -124,7 +125,7 @@ class ActiveStarter<ActiveDispatcher>
|
||||
/// for ActiveDispatcher.
|
||||
{
|
||||
public:
|
||||
static void start(ActiveDispatcher* pOwner, Runnable* pRunnable)
|
||||
static void start(ActiveDispatcher* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
||||
{
|
||||
pOwner->start(pRunnable);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveMethod.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveMethod.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveMethod.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ActiveMethod class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "Poco/ActiveResult.h"
|
||||
#include "Poco/ActiveRunnable.h"
|
||||
#include "Poco/ActiveStarter.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -109,7 +110,7 @@ public:
|
||||
/// Invokes the ActiveMethod.
|
||||
{
|
||||
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
||||
ActiveRunnableType* pRunnable = new ActiveRunnableType(_pOwner, _method, arg, result);
|
||||
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, arg, result));
|
||||
StarterType::start(_pOwner, pRunnable);
|
||||
return result;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveResult.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveResult.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveResult.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ActiveResult class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(const ActiveResult& result)
|
||||
void swap(ActiveResult& result)
|
||||
{
|
||||
using std::swap;
|
||||
swap(_pHolder, result._pHolder);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveRunnable.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveRunnable.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveRunnable.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ActiveRunnable class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -43,14 +43,24 @@
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/ActiveResult.h"
|
||||
#include "Poco/Runnable.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class ActiveRunnableBase: public Runnable, public RefCountedObject
|
||||
/// The base class for all ActiveRunnable instantiations.
|
||||
{
|
||||
public:
|
||||
typedef AutoPtr<ActiveRunnableBase> Ptr;
|
||||
};
|
||||
|
||||
|
||||
template <class ResultType, class ArgType, class OwnerType>
|
||||
class ActiveRunnable: public Runnable
|
||||
class ActiveRunnable: public ActiveRunnableBase
|
||||
/// This class is used by ActiveMethod.
|
||||
/// See the ActiveMethod class for more information.
|
||||
{
|
||||
@@ -69,6 +79,7 @@ public:
|
||||
|
||||
void run()
|
||||
{
|
||||
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||
try
|
||||
{
|
||||
_result.data(new ResultType((_pOwner->*_method)(_arg)));
|
||||
@@ -86,7 +97,6 @@ public:
|
||||
_result.error("unknown exception");
|
||||
}
|
||||
_result.notify();
|
||||
delete this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveStarter.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveStarter.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveStarter.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ActiveStarter class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -42,14 +42,12 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/ThreadPool.h"
|
||||
#include "Poco/ActiveRunnable.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Runnable;
|
||||
|
||||
|
||||
template <class OwnerType>
|
||||
class ActiveStarter
|
||||
/// The default implementation of the StarterType
|
||||
@@ -58,9 +56,10 @@ class ActiveStarter
|
||||
/// thread pool.
|
||||
{
|
||||
public:
|
||||
static void start(OwnerType* pOwner, Runnable* pRunnable)
|
||||
static void start(OwnerType* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
||||
{
|
||||
ThreadPool::defaultPool().start(*pRunnable);
|
||||
pRunnable->duplicate(); // The runnable will release itself.
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
//
|
||||
// ActiveDispatcher.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/ActiveDispatcher.cpp#4 $
|
||||
// $Id: //poco/Main/Foundation/src/ActiveDispatcher.cpp#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: ActiveObjects
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -47,18 +47,18 @@ namespace
|
||||
class MethodNotification: public Notification
|
||||
{
|
||||
public:
|
||||
MethodNotification(Runnable* pRunnable):
|
||||
MethodNotification(ActiveRunnableBase::Ptr pRunnable):
|
||||
_pRunnable(pRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
Runnable* runnable() const
|
||||
ActiveRunnableBase::Ptr runnable() const
|
||||
{
|
||||
return _pRunnable;
|
||||
}
|
||||
|
||||
private:
|
||||
Runnable* _pRunnable;
|
||||
ActiveRunnableBase::Ptr _pRunnable;
|
||||
};
|
||||
|
||||
class StopNotification: public Notification
|
||||
@@ -92,7 +92,7 @@ ActiveDispatcher::~ActiveDispatcher()
|
||||
}
|
||||
|
||||
|
||||
void ActiveDispatcher::start(Runnable* pRunnable)
|
||||
void ActiveDispatcher::start(ActiveRunnableBase::Ptr pRunnable)
|
||||
{
|
||||
poco_check_ptr (pRunnable);
|
||||
|
||||
@@ -113,9 +113,9 @@ void ActiveDispatcher::run()
|
||||
{
|
||||
MethodNotification* pMethodNf = dynamic_cast<MethodNotification*>(pNf.get());
|
||||
poco_check_ptr (pMethodNf);
|
||||
Runnable* pRunnable = pMethodNf->runnable();
|
||||
poco_check_ptr (pRunnable);
|
||||
pRunnable->run();
|
||||
ActiveRunnableBase::Ptr pRunnable = pMethodNf->runnable();
|
||||
pRunnable->duplicate(); // run will release
|
||||
pRunnable->run();
|
||||
pNf = _queue.waitDequeueNotification();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user