Changeset 1764 for XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services.cpp
- Timestamp:
- 11/05/19 16:02:34 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services.cpp
r1761 r1764 10 10 CService::CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, 11 11 int type, int nbPartitions) : finalizeSignal_(false), eventScheduler_(nullptr), poolId_(poolId), serviceId_(serviceId), 12 partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions) 12 partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions), hasNotification_(false) 13 13 14 14 … … 34 34 } 35 35 eventScheduler_ = new CEventScheduler(serviceComm_) ; 36 37 ostringstream oss; 38 oss<<partitionId; 39 name_= poolId+"::"+serviceId+"_"+oss.str(); 36 40 } 37 41 … … 41 45 MPI_Comm_size(serviceComm_, &commSize) ; 42 46 43 for(int rank=0; rank<commSize; rank++) createContextNotify(rank, poolId, serviceId, partitionId, contextId) ; 47 for(int rank=0; rank<commSize; rank++) 48 { 49 notifyOutType_=NOTIFY_CREATE_CONTEXT ; 50 notifyOutCreateContext_ = make_tuple(poolId, serviceId, partitionId, contextId) ; 51 sendNotification(rank) ; 52 } 44 53 } 45 54 /* … … 87 96 } 88 97 89 bool CService::eventLoop(void) 90 { 91 checkCreateContextNotification() ; 98 bool CService::eventLoop(bool serviceOnly) 99 { 100 //checkCreateContextNotification() ; 101 checkNotifications() ; 102 92 103 eventScheduler_->checkEvent() ; 93 104 for(auto it=contexts_.begin();it!=contexts_.end();++it) 94 105 { 95 if (it->second->eventLoop( ))106 if (it->second->eventLoop(serviceOnly)) 96 107 { 97 108 contexts_.erase(it) ; … … 105 116 } 106 117 118 void CService::sendNotification(int rank) 119 { 120 winNotify_->lockWindow(rank,0) ; 121 winNotify_->pushToWindow(rank, this, &CService::notificationsDumpOut) ; 122 winNotify_->unlockWindow(rank,0) ; 123 } 124 125 126 void CService::notificationsDumpOut(CBufferOut& buffer) 127 { 128 129 buffer.realloc(maxBufferSize_) ; 130 131 if (notifyOutType_==NOTIFY_CREATE_CONTEXT) 132 { 133 auto& arg=notifyOutCreateContext_ ; 134 buffer << notifyOutType_ << std::get<0>(arg)<<std::get<1>(arg) << std::get<2>(arg)<<std::get<3>(arg) ; 135 } 136 } 137 138 void CService::notificationsDumpIn(CBufferIn& buffer) 139 { 140 if (buffer.bufferSize() == 0) notifyInType_= NOTIFY_NOTHING ; 141 else 142 { 143 buffer>>notifyInType_; 144 if (notifyInType_==NOTIFY_CREATE_CONTEXT) 145 { 146 info(10)<<"NotifyDumpOut"<<endl ; 147 auto& arg=notifyInCreateContext_ ; 148 buffer >> std::get<0>(arg)>> std::get<1>(arg) >> std::get<2>(arg)>> std::get<3>(arg); 149 } 150 } 151 } 152 153 154 155 156 void CService::checkNotifications(void) 157 { 158 if (!hasNotification_) 159 { 160 int commRank ; 161 MPI_Comm_rank(serviceComm_, &commRank) ; 162 winNotify_->lockWindow(commRank,0) ; 163 winNotify_->popFromWindow(commRank, this, &CService::notificationsDumpIn) ; 164 winNotify_->unlockWindow(commRank,0) ; 165 166 if (notifyInType_!= NOTIFY_NOTHING) 167 { 168 hasNotification_=true ; 169 std::hash<string> hashString ; 170 size_t hashId = hashString(name_) ; 171 size_t currentTimeLine=0 ; 172 eventScheduler_->registerEvent(currentTimeLine,hashId); 173 } 174 } 175 176 if (hasNotification_) 177 { 178 std::hash<string> hashString ; 179 size_t hashId = hashString(name_) ; 180 size_t currentTimeLine=0 ; 181 if (eventScheduler_->queryEvent(currentTimeLine,hashId)) 182 { 183 if (notifyInType_==NOTIFY_CREATE_CONTEXT) createContext() ; 184 hasNotification_=false ; 185 } 186 } 187 } 188 189 190 191 107 192 void CService::checkCreateContextNotification(void) 108 193 { … … 122 207 } 123 208 209 void CService::createContext(void) 210 { 211 auto& arg=notifyInCreateContext_ ; 212 string poolId = get<0>(arg) ; 213 string& serviceId = get<1>(arg) ; 214 int partitionId = get<2>(arg) ; 215 string contextId = get<3>(arg) ; 216 contexts_[contextId] = new CServerContext(this, serviceComm_, poolId, serviceId, partitionId, contextId) ; 217 } 218 219 //to remove 124 220 void CService::createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) 125 221 {
Note: See TracChangeset
for help on using the changeset viewer.