Index: XIOS3/trunk/src/manager/pool_ressource.cpp
===================================================================
--- XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2403)
+++ XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2404)
@@ -27,5 +27,5 @@
     
     winNotify_->lockWindow(commRank,0) ;
-    winNotify_->updateToWindow(commRank, this, &CPoolRessource::createServiceDumpOut) ;  
+    winNotify_->updateToWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ;
     winNotify_->unlockWindow(commRank,0) ;       
     MPI_Barrier(poolComm_) ;
@@ -60,5 +60,18 @@
   }
 
-  
+  void CPoolRessource::createServiceOnto(const std::string& serviceId, int type, const std::string& onServiceId)
+  {
+    // for now suppose nbPartitions=1
+    
+    auto it=occupancy_.begin() ;
+    int commSize ;
+    MPI_Comm_size(poolComm_, &commSize) ;
+    
+    info(40)<<"CPoolRessource::createService  : notify createServiceOnto to all pool members ; serviceId : "<<serviceId
+            <<"  onto service Id  :"<< serviceId<<endl ;
+    for(int rank=0; rank<commSize; rank++) createServiceOntoNotify(rank, serviceId, type, onServiceId) ;
+  }
+
+/*  
   void CPoolRessource::createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, 
                                            bool in)
@@ -70,6 +83,90 @@
     winNotify_->unlockWindow(rank,0) ;   
   }
-
-
+*/
+  
+  void CPoolRessource::createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in)
+  {
+    notifyType_=NOTIFY_CREATE_SERVICE ;
+    notifyCreateService_=make_tuple(serviceId, type, size, nbPartitions, in ) ;
+    sendNotification(rank) ;
+  }
+
+
+  void CPoolRessource::createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId)
+  {
+    notifyType_=NOTIFY_CREATE_SERVICE_ONTO ;
+    notifyCreateServiceOnto_=make_tuple(serviceId, type, onServiceId) ;
+    sendNotification(rank) ;
+  }
+
+
+  void CPoolRessource::sendNotification(int rank)
+  {
+    winNotify_->lockWindowExclusive(rank) ;
+    winNotify_->pushToLockedWindow(rank, this, &CPoolRessource::notificationsDumpOut) ;
+    winNotify_->unlockWindow(rank) ;
+  }
+
+  void CPoolRessource::checkNotifications(void)
+  {
+    int commRank ;
+    MPI_Comm_rank(poolComm_, &commRank) ;
+    winNotify_->lockWindowExclusive(commRank) ;
+    winNotify_->popFromLockedWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ;
+    winNotify_->unlockWindow(commRank) ;
+    if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ;
+    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ;
+  }
+
+
+  void CPoolRessource::notificationsDumpOut(CBufferOut& buffer)
+  {
+
+    buffer.realloc(maxBufferSize_) ;
+    
+    if (notifyType_==NOTIFY_CREATE_SERVICE)
+    {
+      auto& arg=notifyCreateService_ ;
+      buffer << notifyType_<< get<0>(arg) << get<1>(arg) << std::get<2>(arg) << get<3>(arg) << get<4>(arg);
+    }
+    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO)
+    {
+      auto& arg=notifyCreateServiceOnto_ ;
+      buffer << notifyType_<< get<0>(arg) << get<1>(arg)<< get<2>(arg)  ;
+    }
+  }
+
+  void CPoolRessource::notificationsDumpIn(CBufferIn& buffer)
+  {
+    if (buffer.bufferSize() == 0) notifyType_= NOTIFY_NOTHING ;
+    else
+    {
+      buffer>>notifyType_;
+      if (notifyType_==NOTIFY_CREATE_SERVICE)
+      {
+        auto& arg=notifyCreateService_ ;
+        buffer >> get<0>(arg) >> get<1>(arg) >> std::get<2>(arg)>> get<3>(arg)>> get<4>(arg) ;
+      }
+      else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO)
+      {
+        auto& arg=notifyCreateServiceOnto_ ;
+        buffer >> get<0>(arg) >> get<1>(arg) >> get<2>(arg) ;
+      }
+    }
+  }  
+
+  void CPoolRessource::createService(void)
+  {
+    auto& arg = notifyCreateService_ ;
+    createNewService(get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg), get<4>(arg)) ;
+  }
+  
+  void CPoolRessource::createServiceOnto(void)
+  {
+    auto& arg = notifyCreateServiceOnto_ ;
+    createNewServiceOnto(get<0>(arg), get<1>(arg), get<2>(arg)) ;
+  }
+
+/*
   void CPoolRessource::createServiceDumpOut(CBufferOut& buffer)
   {
@@ -82,5 +179,7 @@
   }
 
-
+*/
+
+/*
   void CPoolRessource::createServiceDumpIn(CBufferIn& buffer)
   {
@@ -100,4 +199,5 @@
     }
   }
+*/
 
   bool CPoolRessource::eventLoop(bool serviceOnly)
@@ -110,5 +210,6 @@
     if (time-lastEventLoop_ > eventLoopLatency_) 
     {
-      checkCreateServiceNotification() ;
+      //checkCreateServiceNotification() ;
+      checkNotifications() ;
       lastEventLoop_=time ;
     }
@@ -128,5 +229,5 @@
     else return false ;
   }
-
+/*
   void CPoolRessource::checkCreateServiceNotification(void)
   {
@@ -146,4 +247,5 @@
 
   }
+*/
 
   void CPoolRessource::createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in)
@@ -186,4 +288,27 @@
      MPI_Comm_free(&serviceComm) ;
   }
+  
+  void CPoolRessource::createNewServiceOnto(const std::string& serviceId, int type, const std::string& onServiceId)
+  {
+     
+    info(40)<<"CPoolRessource::createNewServiceOnto  : receive createServiceOnto notification ; serviceId : "
+            <<serviceId<<"  ontoServiceId : "<<onServiceId<<endl ;
+    for(auto& service : services_) 
+    {
+      if (std::get<0>(service.first)==onServiceId)
+      {
+        const MPI_Comm& serviceComm = service.second->getCommunicator() ;
+        MPI_Comm newServiceComm ;
+        MPI_Comm_dup(serviceComm, &newServiceComm) ;
+        int nbPartitions = service.second->getNbPartitions() ;
+        int partitionId = service.second->getPartitionId() ;
+        shared_ptr<CEventScheduler>  eventScheduler = service.second->getEventScheduler() ;
+        info(40)<<"CPoolRessource::createNewServiceOnto ; found onServiceId : "<<onServiceId<<endl  ;
+        services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, Id_, serviceId, partitionId, type,
+                                                                         nbPartitions, eventScheduler) ;       
+      }
+    }
+    
+  }
 
   void CPoolRessource::createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) // for clients & attached
Index: XIOS3/trunk/src/manager/pool_ressource.hpp
===================================================================
--- XIOS3/trunk/src/manager/pool_ressource.hpp	(revision 2403)
+++ XIOS3/trunk/src/manager/pool_ressource.hpp	(revision 2404)
@@ -21,5 +21,10 @@
     CWindowManager* winNotify_ ;
     
-   public:
+    private:
+    const int NOTIFY_NOTHING=0 ;
+    const int NOTIFY_CREATE_SERVICE=1 ;
+    const int NOTIFY_CREATE_SERVICE_ONTO=2 ;
+
+    public:
     CPoolRessource(MPI_Comm poolComm, const std::string& Id) ;
     ~CPoolRessource() ;
@@ -27,19 +32,39 @@
     void createService(const std::string& serviceId, int type, int size, int nbPartition) ;
     void createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) ; 
-    void createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
-    void createServiceDumpOut(CBufferOut& buffer) ;
-    void createServiceDumpIn(CBufferIn& buffer) ;
-    void checkCreateServiceNotification(void) ;
-    void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
-     bool eventLoop(bool serviceOnly=false) ;
+    void createServiceOnto(const std::string& serviceId, int type, const std::string& OnServiceId) ;
+    bool eventLoop(bool serviceOnly=false) ;
     CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; }
     void finalizeSignal(void) ;
     string getId(void) { return Id_; }
+
+  private:
+    void createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in) ;
+    void createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId) ;
+    void sendNotification(int rank) ;
+    void checkNotifications(void) ;
+    void notificationsDumpOut(CBufferOut& buffer) ;
+    void notificationsDumpIn(CBufferIn& buffer) ;
+    void createService(void) ;
+    void createServiceOnto(void) ;
     
-   private:
+//    void createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
+//    void createServiceDumpOut(CBufferOut& buffer) ;
+//    void createServiceDumpIn(CBufferIn& buffer) ;
+//    void checkCreateServiceNotification(void) ;
+    void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
+    void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ;
+    
+    private:
     MPI_Comm poolComm_ ;
     
     std::multimap<int,int> occupancy_ ;
-    std::list<std::tuple<std::string, int, int, int, bool> > notifications_;
+
+//    std::list<std::tuple<std::string, int, int, int, bool> > notifications_;
+    
+    int notifyType_ ;
+    tuple<std::string, int, int, int, bool> notifyCreateService_ ;
+    tuple<std::string, int, std::string> notifyCreateServiceOnto_ ;
+
+
     std::map< std::tuple<std::string, int>, CService*> services_ ;
     std::string Id_ ;
Index: XIOS3/trunk/src/manager/services.cpp
===================================================================
--- XIOS3/trunk/src/manager/services.cpp	(revision 2403)
+++ XIOS3/trunk/src/manager/services.cpp	(revision 2404)
@@ -10,6 +10,7 @@
 {
   CService::CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, 
-                     int type, int nbPartitions) : finalizeSignal_(false), eventScheduler_(nullptr), poolId_(poolId), serviceId_(serviceId),
-                                                   partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions), hasNotification_(false)
+                     int type, int nbPartitions, shared_ptr<CEventScheduler> eventScheduler) 
+                         : finalizeSignal_(false), eventScheduler_(nullptr), poolId_(poolId), serviceId_(serviceId),
+                           partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions), hasNotification_(false)
 
 
@@ -36,5 +37,6 @@
       CXios::getServicesManager()->registerService(poolId, serviceId, partitionId, type, commSize, nbPartitions, globalLeader_) ;
     }
-    eventScheduler_ = new CEventScheduler(serviceComm_) ;
+    if (eventScheduler) eventScheduler_ = eventScheduler ;
+    eventScheduler_ = make_shared<CEventScheduler>(serviceComm_) ;
 
     ostringstream oss;
@@ -45,5 +47,4 @@
   CService::~CService()
   {
-    delete eventScheduler_ ;
     delete winNotify_ ;
     for(auto& it : contexts_) delete it.second ;
@@ -262,5 +263,5 @@
   }
 
-  CEventScheduler* CService::getEventScheduler(void)
+  shared_ptr<CEventScheduler> CService::getEventScheduler(void)
   {
     return eventScheduler_ ;
Index: XIOS3/trunk/src/manager/services.hpp
===================================================================
--- XIOS3/trunk/src/manager/services.hpp	(revision 2403)
+++ XIOS3/trunk/src/manager/services.hpp	(revision 2404)
@@ -20,5 +20,5 @@
 
     CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, 
-             int type, int nbPartitions) ;
+             int type, int nbPartitions, shared_ptr<CEventScheduler> = nullptr) ;
     ~CService() ;
 
@@ -32,5 +32,5 @@
     CServerContext* getServerContext(const std::string& contextId) { return contexts_[contextId]; }
     void finalizeSignal(void) ;
-    CEventScheduler* getEventScheduler(void) ;
+    shared_ptr<CEventScheduler> getEventScheduler(void) ;
 
     std::string getPoolId(void) {return poolId_;}
@@ -39,4 +39,5 @@
     int getType(void) {return type_;}
     int getNbPartitions(void) {return nbPartitions_;}
+    const MPI_Comm& getCommunicator(void) { return serviceComm_ ;}
     
     private:
@@ -65,5 +66,5 @@
     std::map<std::string, CServerContext*> contexts_ ;
     bool finalizeSignal_ ;
-    CEventScheduler* eventScheduler_ ;
+    shared_ptr<CEventScheduler> eventScheduler_ ;
 
     std::string poolId_ ;
Index: XIOS3/trunk/src/manager/services_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/services_manager.cpp	(revision 2403)
+++ XIOS3/trunk/src/manager/services_manager.cpp	(revision 2404)
@@ -76,5 +76,5 @@
   }
 
-  bool CServicesManager::createServicesOnto(const std::string& poolId, const std::string& serviceId, const std::string& OnServiceId, bool wait)
+  bool CServicesManager::createServicesOnto(const std::string& poolId, const std::string& serviceId, int type, const std::string& OnServiceId, bool wait)
   {
 
@@ -96,5 +96,5 @@
     {
       info(40)<<"CServicesManager : create service on other, notification to leader "<<leader<<", serviceId : "<<serviceId<<", service onto : "<<OnServiceId<<endl ;
-      createServicesOntoNotify(leader, serviceId, OnServiceId) ;
+      createServicesOntoNotify(leader, serviceId, type, OnServiceId) ;
       return true ;
     }
@@ -110,8 +110,8 @@
 
 
-  void CServicesManager::createServicesOntoNotify(int rank, const string& serviceId, const string& OnServiceId)
+  void CServicesManager::createServicesOntoNotify(int rank, const string& serviceId, int type, const string& OnServiceId)
   {
     notifyType_=NOTIFY_CREATE_SERVICE_ONTO ;
-    notifyCreateServiceOnto_=make_tuple(serviceId, OnServiceId) ;
+    notifyCreateServiceOnto_=make_tuple(serviceId, type, OnServiceId) ;
     sendNotification(rank) ;
   }
@@ -160,6 +160,6 @@
   void CServicesManager::createServiceOnto(void)
   {
-    auto& arg=notifyCreateService_ ;
-    //CServer::getServersRessource()->getPoolRessource()->createService(get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg)) ;
+    auto& arg=notifyCreateServiceOnto_ ;
+    CServer::getServersRessource()->getPoolRessource()->createServiceOnto(get<0>(arg), get<1>(arg), get<2>(arg)) ;
   }
 
@@ -177,5 +177,5 @@
     {
       auto& arg=notifyCreateServiceOnto_ ;
-      buffer << notifyType_<< get<0>(arg) << get<1>(arg)  ;
+      buffer << notifyType_<< get<0>(arg) << get<1>(arg) << get<2>(arg)  ;
     }
   }
@@ -195,5 +195,5 @@
       {
         auto& arg=notifyCreateServiceOnto_ ;
-        buffer >> get<0>(arg) >> get<1>(arg) ;
+        buffer >> get<0>(arg) >> get<1>(arg) >> get<2>(arg) ;
       }
     }
Index: XIOS3/trunk/src/manager/services_manager.hpp
===================================================================
--- XIOS3/trunk/src/manager/services_manager.hpp	(revision 2403)
+++ XIOS3/trunk/src/manager/services_manager.hpp	(revision 2404)
@@ -38,5 +38,5 @@
     
     bool createServices(const std::string& poolId, const std::string& serviceId, int type, int size, int nbPartition, bool wait=true) ;
-    bool createServicesOnto(const std::string& poolId, const std::string& serviceId, const std::string& onServiceId, bool wait=true) ;
+    bool createServicesOnto(const std::string& poolId, const std::string& serviceId, int type, const std::string& onServiceId, bool wait=true) ;
     
     void eventLoop(void) ;
@@ -56,5 +56,5 @@
     void createServiceOnto(void) ;    
     void createServicesNotify(int rank, const string& serviceId, int type, int size, int nbPartitions) ;
-    void createServicesOntoNotify(int rank, const string& serviceId, const string& OnServiceId) ;
+    void createServicesOntoNotify(int rank, const string& serviceId, int type, const string& OnServiceId) ;
     void sendNotification(int rank) ;
     void checkNotifications(void) ;
@@ -73,5 +73,5 @@
     int notifyType_ ;
     tuple<std::string, int, int, int> notifyCreateService_ ;
-    tuple<std::string, std::string> notifyCreateServiceOnto_ ;
+    tuple<std::string, int, std::string> notifyCreateServiceOnto_ ;
    
     std::map<tuple<std::string, std::string, int>, std::tuple<int, int, int, int> > services_ ;
Index: XIOS3/trunk/src/node/context.hpp
===================================================================
--- XIOS3/trunk/src/node/context.hpp	(revision 2403)
+++ XIOS3/trunk/src/node/context.hpp	(revision 2404)
@@ -342,5 +342,5 @@
         
       private:
-         CEventScheduler* eventScheduler_ ; //! The local event scheduler for context
+         shared_ptr<CEventScheduler> eventScheduler_ ; //! The local event scheduler for context
          size_t hashId_ ; //! the local hashId for scheduler
          size_t timeLine_=0 ;
Index: XIOS3/trunk/src/server.cpp
===================================================================
--- XIOS3/trunk/src/server.cpp	(revision 2403)
+++ XIOS3/trunk/src/server.cpp	(revision 2404)
@@ -190,4 +190,5 @@
           ressourcesManager->createPool(CXios::defaultPoolId, nbRessources) ;
           servicesManager->createServices(CXios::defaultPoolId, CXios::defaultServerId, CServicesManager::IO_SERVER,nbRessources,1) ;
+          servicesManager->createServicesOnto(CXios::defaultPoolId, "default_reader", CServicesManager::READER, CXios::defaultServerId) ;
         }
         else
Index: XIOS3/trunk/src/transport/context_server.hpp
===================================================================
--- XIOS3/trunk/src/transport/context_server.hpp	(revision 2403)
+++ XIOS3/trunk/src/transport/context_server.hpp	(revision 2404)
@@ -48,5 +48,5 @@
 
       size_t hashId ;
-      CEventScheduler* eventScheduler_=nullptr ;
+      shared_ptr<CEventScheduler> eventScheduler_=nullptr ;
   } ;
   
