Commit 117f1e66 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

remove workerManager

parent c553c068
......@@ -57,16 +57,17 @@ int main(int argc, char **argv)
// FIXME: don't hardcode plugin
dtkDistributedPolicy policy;
dtkDistributedWorkerManager manager;
policy.setType("mpi3");
manager.setPolicy(&policy);
//FIXME: don't use manager
// dtkDistributedWorkerManager manager;
// policy.setType("mpi3");
// manager.setPolicy(&policy);
dtkComposerEvaluatorProcess p;
QStringList hosts;
// dtkDistributedCommunicator *comm = manager.spawn();
dtkDistributedCommunicator *comm ;
manager.spawn();
//manager.spawn();
p.setInternalCommunicator(comm);
p.setParentCommunicator(policy.communicator());
......
......@@ -98,7 +98,6 @@ void dtkComposerNodeSpawn::begin(void)
d->policy.setNThreads(d->np);
// FIXME: don't use hardcoded plugin name
d->policy.setType("qthreads");
d->manager.setPolicy(&d->policy);
d->communicator = d->policy.communicator();
// d->internal_comm = d->manager.spawn();
d->internal_comm_emitter.setData(d->internal_comm);
......@@ -115,7 +114,8 @@ void dtkComposerNodeSpawn::begin(void)
// p.setParentCommunicator(comm);
// p.setFactory(factory);
d->manager.exec(&p);
//FIXME: don't use manager
// d->manager.exec(&p);
} else {
dtkTrace() << "communicator exists, no spawn";
......
......@@ -17,7 +17,6 @@
#include "dtkComposerNodeRemote_p.h"
#include <dtkDistributed/dtkDistributedWorkerManager.h>
#include <dtkDistributed/dtkDistributedCommunicator.h>
......@@ -38,7 +37,6 @@ public:
public:
dtkDistributedCommunicator *internal_comm;
dtkDistributedWorkerManager manager;
dtkDistributedPolicy policy;
public:
......
......@@ -57,8 +57,7 @@ set(${PROJECT_NAME}_HEADERS
dtkDistributedSettings
dtkDistributedSettings.h
dtkDistributedSlave.h
dtkDistributedWorkerManager
dtkDistributedWorkerManager.h)
)
set(${PROJECT_NAME}_SOURCES
dtkDistributed.cpp
......@@ -77,7 +76,7 @@ set(${PROJECT_NAME}_SOURCES
dtkDistributedServerDaemon.cpp
dtkDistributedSettings.cpp
dtkDistributedSlave.cpp
dtkDistributedWorkerManager.cpp)
)
## #################################################################
## Build rules
......
......@@ -12,4 +12,3 @@
#include "dtkDistributedRequest.h"
#include "dtkDistributedSettings.h"
#include "dtkDistributedSlave.h"
#include "dtkDistributedWorkerManager.h"
......@@ -60,6 +60,27 @@ namespace dtkDistributed
return _private::app->policy();
}
void spawn(void) {
if (!app())
return;
_private::app->spawn();
}
void exec(QRunnable *task) {
if (!app())
return;
_private::app->exec(task);
}
void unspawn(void) {
if (!app())
return;
_private::app->unspawn();
}
namespace communicator
{
namespace _private {
......
......@@ -15,6 +15,7 @@
#pragma once
#include "dtkDistributedExport.h"
#include <QtCore>
class dtkDistributedAbstractApplication;
class dtkDistributedCoreApplication;
......@@ -62,6 +63,21 @@ namespace dtkDistributed
DTKDISTRIBUTED_EXPORT dtkDistributedPolicy *policy(void);
#pragma mark -
#pragma mark spawn application
DTKDISTRIBUTED_EXPORT void spawn(void);
#pragma mark -
#pragma mark execute task
DTKDISTRIBUTED_EXPORT void exec(QRunnable *task);
#pragma mark -
#pragma mark unspawn application
DTKDISTRIBUTED_EXPORT void unspawn(void);
#pragma mark -
#pragma mark Modular concepts
......
......@@ -19,7 +19,6 @@
#include "dtkDistributedCommunicator"
#include "dtkDistributedCoreApplication.h"
#include "dtkDistributedSettings.h"
#include "dtkDistributedWorkerManager.h"
#include "dtkDistributedPolicy.h"
#include <dtkLog>
......@@ -30,22 +29,22 @@ class dtkDistributedAbstractApplicationPrivate
{
public:
dtkDistributedWorkerManager manager;
dtkDistributedPolicy policy;
bool spawned;
};
dtkDistributedAbstractApplication::dtkDistributedAbstractApplication(void)
{
d = new dtkDistributedAbstractApplicationPrivate;
d->spawned = false;
}
dtkDistributedAbstractApplication::~dtkDistributedAbstractApplication(void)
{
d->manager.unspawn();
if (d->spawned)
this->unspawn();
delete d;
d = NULL;
......@@ -81,14 +80,26 @@ void dtkDistributedAbstractApplication::initialize(void)
}
d->policy.setType(policyType);
d->manager.setPolicy(&(d->policy));
d->manager.spawn();
this->spawn();
}
void dtkDistributedAbstractApplication::exec(QRunnable *task)
{
d->manager.exec(task);
d->policy.communicator()->exec(task);
}
void dtkDistributedAbstractApplication::spawn(void)
{
QStringList hosts = d->policy.hosts();
d->spawned = true;
d->policy.communicator()->spawn(hosts, d->policy.nthreads());
}
void dtkDistributedAbstractApplication::unspawn(void)
{
d->policy.communicator()->unspawn();
d->spawned = false;
}
dtkDistributedPolicy *dtkDistributedAbstractApplication::policy(void)
......
......@@ -32,6 +32,8 @@ public:
public:
virtual void initialize(void);
virtual void exec(QRunnable *task);
virtual void spawn(void);
virtual void unspawn(void);
public:
bool isMaster(void);
......
#include "dtkDistributedWorkerManager.h"
/* @(#)dtkDistributedWorkerManager.cpp ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2013 - Nicolas Niclausse, Inria.
* Created: 2013/02/14 13:20:59
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#include "dtkDistributedWorkerManager.h"
#include "dtkDistributedCommunicator.h"
#include "dtkDistributedPolicy.h"
class dtkDistributedWorkerManagerPrivate
{
public:
dtkDistributedCommunicator *comm;
dtkDistributedPolicy *policy;
public:
bool spawned;
};
dtkDistributedWorkerManager::dtkDistributedWorkerManager(void) : QObject(), d(new dtkDistributedWorkerManagerPrivate)
{
d->comm = NULL;
d->policy = NULL;
d->spawned = false;
}
dtkDistributedWorkerManager::~dtkDistributedWorkerManager(void)
{
delete d;
d = NULL;
}
dtkDistributedWorkerManager::dtkDistributedWorkerManager(const dtkDistributedWorkerManager& other)
{
}
dtkDistributedWorkerManager& dtkDistributedWorkerManager::operator = (const dtkDistributedWorkerManager& other)
{
return (*this);
}
void dtkDistributedWorkerManager::setPolicy(dtkDistributedPolicy *policy)
{
d->policy = policy;
d->comm = policy->communicator();
}
void dtkDistributedWorkerManager::spawn(void)
{
if (d->spawned)
return;
// d->worker.setCommunicator(d->comm);
QStringList hosts = d->policy->hosts();
d->comm->spawn(hosts, d->policy->nthreads());
d->spawned = true;
}
void dtkDistributedWorkerManager::exec(QRunnable *work)
{
d->comm->exec( work );
}
void dtkDistributedWorkerManager::unspawn(void)
{
if (!d->spawned)
return;
d->comm->unspawn();
d->spawned = false;
}
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include "dtkDistributedExport.h"
#include <QtCore>
class dtkDistributedCommunicator;
class dtkDistributedPolicy;
class dtkDistributedWorkerManagerPrivate;
class DTKDISTRIBUTED_EXPORT dtkDistributedWorkerManager: public QObject
{
Q_OBJECT
public:
dtkDistributedWorkerManager(void);
virtual ~dtkDistributedWorkerManager(void);
public:
dtkDistributedWorkerManager(const dtkDistributedWorkerManager& other);
dtkDistributedWorkerManager& operator = (const dtkDistributedWorkerManager& other);
public:
void setPolicy(dtkDistributedPolicy *policy);
public:
void spawn(void);
void exec(QRunnable *work);
void unspawn(void);
public:
dtkDistributedWorkerManagerPrivate *d;
};
//
// dtkDistributedWorkerManager.h ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment