|
@@ -387,7 +387,7 @@ void grpcclient::shareswapmsg(iv::cloud::cloudmsg * pxmsg)
|
|
|
for(i=0;i<nsize;i++)
|
|
|
{
|
|
|
int j;
|
|
|
- int nquerysize = mvectorctrlmsgunit.size();
|
|
|
+ int nquerysize = static_cast<int>(mvectorctrlmsgunit.size());
|
|
|
for(j=0;j<nquerysize;j++)
|
|
|
{
|
|
|
if(strncmp(pxmsg->xclouddata(i).msgname().data(), mvectorctrlmsgunit[j].mstrmsgname,255) == 0)
|
|
@@ -397,7 +397,31 @@ void grpcclient::shareswapmsg(iv::cloud::cloudmsg * pxmsg)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if((mnShareMode == Mode_Inter) &&(pxmsg->xclouddata(i).data().size()>0))
|
|
|
+ {
|
|
|
+ iv::swapmsgbuff xswapbuff;
|
|
|
+ xswapbuff.mstrmsgname = pxmsg->xclouddata(i).msgname();
|
|
|
+ xswapbuff.mndatalen = pxmsg->xclouddata(i).data().size();
|
|
|
+ xswapbuff.mpdata_ptr = std::shared_ptr<char>(new char[xswapbuff.mndatalen]);
|
|
|
+ memcpy(xswapbuff.mpdata_ptr.get(),pxmsg->xclouddata(i).data().data(),xswapbuff.mndatalen);
|
|
|
+ if(mvectorswapbuff.size() < 10000)
|
|
|
+ {
|
|
|
+ mmutexswapbuff.lock();
|
|
|
+ mvectorswapbuff.push_back(xswapbuff);
|
|
|
+ mmutexswapbuff.unlock();
|
|
|
+
|
|
|
+ mcv_swapbuff.notify_all();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" swap buff full. "<<std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void grpcclient::UpdateData(const char *strdata, const unsigned int nSize, const char *strmemname)
|
|
@@ -426,3 +450,46 @@ void grpcclient::SetNodeId(std::string strnodeid,std::string strobjnodeid)
|
|
|
mstrnodeid = strnodeid;
|
|
|
mstrobjnodeid = strobjnodeid;
|
|
|
}
|
|
|
+
|
|
|
+void grpcclient::SetShareMode(ShareMode xMode)
|
|
|
+{
|
|
|
+ mnShareMode = xMode;
|
|
|
+}
|
|
|
+
|
|
|
+int grpcclient::GetSwapBuffData(iv::swapmsgbuff & xswap,int nwaitms)
|
|
|
+{
|
|
|
+ int nrtn = 0;
|
|
|
+ mmutexswapbuff.lock();
|
|
|
+ if(mvectorswapbuff.size()>0)
|
|
|
+ {
|
|
|
+ xswap = mvectorswapbuff[0];
|
|
|
+ mvectorswapbuff.erase(mvectorswapbuff.begin());
|
|
|
+ nrtn = 1;
|
|
|
+ }
|
|
|
+ mmutexswapbuff.unlock();
|
|
|
+
|
|
|
+ if(nrtn == 1)return nrtn;
|
|
|
+
|
|
|
+ if(nwaitms == 0)return 0;
|
|
|
+
|
|
|
+ std::unique_lock<std::mutex> lk(mcvmutex_swapbuff);
|
|
|
+ if(mcv_swapbuff.wait_for(lk, std::chrono::milliseconds(nwaitms)) == std::cv_status::timeout)
|
|
|
+ {
|
|
|
+ lk.unlock();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lk.unlock();
|
|
|
+ }
|
|
|
+
|
|
|
+ mmutexswapbuff.lock();
|
|
|
+ if(mvectorswapbuff.size()>0)
|
|
|
+ {
|
|
|
+ xswap = mvectorswapbuff[0];
|
|
|
+ mvectorswapbuff.erase(mvectorswapbuff.begin());
|
|
|
+ nrtn = 1;
|
|
|
+ }
|
|
|
+ mmutexswapbuff.unlock();
|
|
|
+
|
|
|
+ return nrtn;
|
|
|
+}
|