peo style

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1120 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2008-03-12 11:21:25 +00:00
commit ceeaa4b533
5 changed files with 677 additions and 575 deletions

View file

@ -16,157 +16,167 @@
#include "core/peo_debug.h"
class peoAsyncDataTransfer : public Cooperative, public eoUpdater {
public:
template< typename EndPointType >
peoAsyncDataTransfer(
EndPointType& __endPoint,
Topology& __topology
) : topology( __topology )
class peoAsyncDataTransfer : public Cooperative, public eoUpdater
{
source = new MsgTransferQueue< EndPointType >( __endPoint );
destination = new MsgTransferQueue< EndPointType >( __endPoint );
__topology.add( *this );
}
template< typename EndPointType, typename FunctorType >
public:
template< typename EndPointType >
peoAsyncDataTransfer(
EndPointType& __endPoint,
Topology& __topology,
FunctorType& externalFunctorRef
) : topology( __topology )
{
source = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
destination = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
__topology.add( *this );
}
template< typename SourceEndPointType, typename DestinationEndPointType >
EndPointType& __endPoint,
Topology& __topology
) : topology( __topology )
{
source = new MsgTransferQueue< EndPointType >( __endPoint );
destination = new MsgTransferQueue< EndPointType >( __endPoint );
__topology.add( *this );
}
template< typename EndPointType, typename FunctorType >
peoAsyncDataTransfer(
SourceEndPointType& __source,
DestinationEndPointType& __destination,
Topology& __topology
) : topology( __topology )
{
source = new MsgTransferQueue< SourceEndPointType >( __source );
destination = new MsgTransferQueue< DestinationEndPointType >( __destination );
__topology.add( *this );
}
template< typename SourceEndPointType, typename DestinationEndPointType, typename FunctorType >
EndPointType& __endPoint,
Topology& __topology,
FunctorType& externalFunctorRef
) : topology( __topology )
{
source = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
destination = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
__topology.add( *this );
}
template< typename SourceEndPointType, typename DestinationEndPointType >
peoAsyncDataTransfer(
SourceEndPointType& __source,
DestinationEndPointType& __destination,
Topology& __topology,
FunctorType& externalFunctorRef
) : topology( __topology )
{
source = new MsgTransferQueue< SourceEndPointType >( __source, externalFunctorRef );
destination = new MsgTransferQueue< DestinationEndPointType >( __destination, externalFunctorRef );
__topology.add( *this );
}
~peoAsyncDataTransfer() {
delete source;
delete destination;
}
void operator()();
void pack();
void unpack();
void packSynchronizeReq();
private:
void sendData();
void receiveData();
private:
SourceEndPointType& __source,
DestinationEndPointType& __destination,
Topology& __topology
// the neighboring topology
Topology& topology;
// source and destination end-points
AbstractMsgTransferQueue* source;
AbstractMsgTransferQueue* destination;
std :: queue< Cooperative* > coop_em;
};
) : topology( __topology )
{
source = new MsgTransferQueue< SourceEndPointType >( __source );
destination = new MsgTransferQueue< DestinationEndPointType >( __destination );
__topology.add( *this );
}
template< typename SourceEndPointType, typename DestinationEndPointType, typename FunctorType >
peoAsyncDataTransfer(
SourceEndPointType& __source,
DestinationEndPointType& __destination,
Topology& __topology,
FunctorType& externalFunctorRef
) : topology( __topology )
{
source = new MsgTransferQueue< SourceEndPointType >( __source, externalFunctorRef );
destination = new MsgTransferQueue< DestinationEndPointType >( __destination, externalFunctorRef );
__topology.add( *this );
}
~peoAsyncDataTransfer()
{
delete source;
delete destination;
}
void peoAsyncDataTransfer :: pack() {
void operator()();
void pack();
void unpack();
void packSynchronizeReq();
private:
void sendData();
void receiveData();
private:
// the neighboring topology
Topology& topology;
// source and destination end-points
AbstractMsgTransferQueue* source;
AbstractMsgTransferQueue* destination;
std :: queue< Cooperative* > coop_em;
};
void peoAsyncDataTransfer :: pack()
{
lock ();
::pack( coop_em.front()->getKey() );
source->packMessage();
coop_em.pop();
unlock();
}
void peoAsyncDataTransfer :: unpack() {
void peoAsyncDataTransfer :: unpack()
{
lock ();
destination->unpackMessage();
unlock();
}
void peoAsyncDataTransfer :: packSynchronizeReq() {
void peoAsyncDataTransfer :: packSynchronizeReq()
{
}
void peoAsyncDataTransfer :: sendData() {
void peoAsyncDataTransfer :: sendData()
{
std :: vector< Cooperative* > in, out;
topology.setNeighbors( this, in, out );
for ( unsigned i = 0; i < out.size(); i++ ) {
source->pushMessage();
coop_em.push( out[i] );
send( out[i] );
printDebugMessage( "peoAsyncDataTransfer: sending data." );
}
for ( unsigned i = 0; i < out.size(); i++ )
{
source->pushMessage();
coop_em.push( out[i] );
send( out[i] );
printDebugMessage( "peoAsyncDataTransfer: sending data." );
}
}
void peoAsyncDataTransfer :: receiveData() {
void peoAsyncDataTransfer :: receiveData()
{
lock ();
{
while ( !( destination->empty() ) ) {
printDebugMessage( "peoAsyncDataTransfer: received data." );
destination->popMessage();
printDebugMessage( "peoAsyncDataTransfer: done reading data." );
}
while ( !( destination->empty() ) )
{
printDebugMessage( "peoAsyncDataTransfer: received data." );
destination->popMessage();
printDebugMessage( "peoAsyncDataTransfer: done reading data." );
}
}
unlock();
}
void peoAsyncDataTransfer :: operator()() {
void peoAsyncDataTransfer :: operator()()
{
sendData(); // sending data
receiveData(); // receiving data
}