IPread.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "IPstream.H"
00031 #include "long.H"
00032 #include "PstreamGlobals.H"
00033
00034 extern "C"
00035 {
00036 # include <linux/gamma/libgamma.h>
00037 }
00038
00039
00040
00041 namespace Foam
00042 {
00043
00044
00045
00046 IPstream::IPstream
00047 (
00048 const commsTypes commsType,
00049 const int fromProcNo,
00050 const label bufSize,
00051 streamFormat format,
00052 versionNumber version
00053 )
00054 :
00055 Pstream(commsType, bufSize),
00056 Istream(format, version),
00057 fromProcNo_(fromProcNo),
00058 messageSize_(0)
00059 {
00060
00061
00062 setOpened();
00063 setGood();
00064
00065 if (Pstream::debug)
00066 {
00067 Pout<< "IPstream::IPstream : Starting receive from " << fromProcNo_
00068 << " recvIndex:" << PstreamGlobals::recvIndex[fromProcNo_]
00069 << Foam::endl;
00070 }
00071
00072 PstreamGlobals::gammaWait(fromProcNo_);
00073
00074 label ready = PstreamGlobals::consumeIndex[fromProcNo_];
00075 messageSize_ = PstreamGlobals::recvBufLen[ready][fromProcNo_];
00076
00077 if (!bufSize)
00078 {
00079 if (Pstream::debug)
00080 {
00081 Pout<< "IPstream::IPstream : sizing buffer to " << messageSize_
00082 << endl;
00083 }
00084
00085 buf_.setSize(messageSize_);
00086 }
00087
00088 PstreamGlobals::copyReceive(fromProcNo_, buf_.begin(), buf_.size());
00089
00090 if (Pstream::debug)
00091 {
00092 Pout<< "IPstream::IPstream : Received " << messageSize_
00093 << " from " << fromProcNo_
00094 << Foam::endl;
00095 }
00096 }
00097
00098
00099
00100
00101 label IPstream::read
00102 (
00103 const commsTypes commsType,
00104 const int fromProcNo,
00105 char* buf,
00106 const std::streamsize bufSize
00107 )
00108 {
00109
00110 label messageSize;
00111
00112 if (Pstream::debug)
00113 {
00114 Pout<< "IPstream::read : Starting receive from " << fromProcNo
00115 << " recvIndex:" << PstreamGlobals::recvIndex[fromProcNo]
00116 << Foam::endl;
00117 }
00118
00119 PstreamGlobals::gammaWait(fromProcNo);
00120 messageSize = PstreamGlobals::copyReceive(fromProcNo, buf, bufSize);
00121
00122 if (Pstream::debug)
00123 {
00124 Pout<< "IPstream::read : Received " << messageSize
00125 << " from " << fromProcNo
00126 << Foam::endl;
00127 }
00128
00129 return messageSize;
00130 }
00131
00132
00133
00134
00135 }
00136
00137
Copyright © 2000-2009 OpenCFD Ltd