1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Read token and binary block from IPstream
27 \*---------------------------------------------------------------------------*/
31 #include "PstreamGlobals.H"
35 # include <linux/gamma/libgamma.h>
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
47 const commsTypes commsType,
54 Pstream(commsType, bufSize),
55 Istream(format, version),
56 fromProcNo_(fromProcNo),
66 Pout<< "IPstream::IPstream : Starting receive from " << fromProcNo_
67 << " recvIndex:" << PstreamGlobals::recvIndex[fromProcNo_]
71 PstreamGlobals::gammaWait(fromProcNo_);
73 label ready = PstreamGlobals::consumeIndex[fromProcNo_];
74 messageSize_ = PstreamGlobals::recvBufLen[ready][fromProcNo_];
80 Pout<< "IPstream::IPstream : sizing buffer to " << messageSize_
84 buf_.setSize(messageSize_);
87 PstreamGlobals::copyReceive(fromProcNo_, buf_.begin(), buf_.size());
91 Pout<< "IPstream::IPstream : Received " << messageSize_
92 << " from " << fromProcNo_
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 const commsTypes commsType,
103 const int fromProcNo,
105 const std::streamsize bufSize
113 Pout<< "IPstream::read : Starting receive from " << fromProcNo
114 << " recvIndex:" << PstreamGlobals::recvIndex[fromProcNo]
118 PstreamGlobals::gammaWait(fromProcNo);
119 messageSize = PstreamGlobals::copyReceive(fromProcNo, buf, bufSize);
123 Pout<< "IPstream::read : Received " << messageSize
124 << " from " << fromProcNo
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 } // End namespace Foam
136 // ************************************************************************* //