#include "xios_spl.hpp" #include "exception.hpp" #include "buffer_server.hpp" #include "timer.hpp" namespace xios { CServerBuffer::CServerBuffer(vector& windows, vector& winAddress, int windowsRank, StdSize buffSize) : hasWindows(true), windows_(windows), windowsRank_(windowsRank), winAddress_(winAddress) { size = 3 * buffSize; first = 0; current = 1; end = size; used=0 ; MPI_Alloc_mem(size, MPI_INFO_NULL, &buffer) ; currentWindows=1 ; if (windows[0]==MPI_WIN_NULL && windows[1]==MPI_WIN_NULL) hasWindows=false ; } CServerBuffer::~CServerBuffer() { MPI_Free_mem(buffer) ; } void CServerBuffer::updateCurrentWindows(void) { if (currentWindows==0) currentWindows=1 ; else currentWindows=0 ; } bool CServerBuffer::isBufferFree(size_t count) { bool ret ; if (count==0) return true ; if (current>first) { if (current+count0) { ret=true ; } else { ret=false ; } } else { if (countfirst) { if (current+count0) { ret=buffer+current ; current=0 ; } else { ERROR("void* CServerBuffer::getBuffer(size_t count)", <<"cannot allocate required size in buffer") ; } } else { end=current ; if (count