44 bool Foam::OFstreamCollator::writeFile
48 const fileName& fName,
51 IOstream::versionNumber ver,
58 Pout<<
"OFstreamCollator : Writing " << s.size()
59 <<
" bytes to " << fName
60 <<
" using comm " << comm <<
endl;
63 autoPtr<OSstream> osPtr;
80 OSstream& os = osPtr();
93 UList<char> slice(const_cast<char*>(s.data()),
label(s.size()));
99 List<std::streamoff> start;
110 if (osPtr.valid() && !osPtr().good())
118 Pout<<
"OFstreamCollator : Finished writing " << s.size()
119 <<
" bytes to " << fName
120 <<
" using comm " << comm <<
endl;
127 void* Foam::OFstreamCollator::writeAll(
void *threadarg)
129 OFstreamCollator& handler = *
static_cast<OFstreamCollator*
>(threadarg);
139 if (handler.objects_.size())
141 ptr = handler.objects_.pop();
166 <<
"Failed writing " << ptr->pathName_
177 Pout<<
"OFstreamCollator : Exiting write thread " <<
endl;
182 handler.threadRunning_ =
false;
194 maxBufferSize_(maxBufferSize),
208 threadRunning_(false),
228 Pout<<
"~OFstreamCollator : Waiting for write thread" <<
endl;
253 const word& typeName,
262 if (maxBufferSize_ > 0)
272 totalSize += iter()->data_.size();
280 || (totalSize+off_t(data.size()) < maxBufferSize_)
288 Pout<<
"OFstreamCollator : Waiting for buffer space." 289 <<
" Currently in use:" << totalSize
290 <<
" limit:" << maxBufferSize_
299 Pout<<
"OFstreamCollator : relaying write of " << fName
300 <<
" to thread " <<
endl;
306 new writeData(typeName, fName, data, fmt, ver, cmp, append)
318 Pout<<
"OFstreamCollator : Started write thread " <<
endl;
320 threadRunning_ =
true;
330 return writeFile(comm_, typeName, fName, data, fmt, ver, cmp, append);
A FIFO stack based on a singly-linked list.
void freeMutex(const label)
Free a mutex variable.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
Inter-processor communication reduction functions.
virtual ~OFstreamCollator()
Destructor.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
static bool writeBlocks(const label comm, autoPtr< OSstream > &osPtr, List< std::streamoff > &start, const UList< char > &, const UPstream::commsTypes, const bool syncReturnState=true)
Write *this. Ostream only valid on master. Returns starts of.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
void unlockMutex(const label)
Unlock a mutex variable.
void freeThread(const label)
Delete a thread.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A class for handling words, derived from string.
static void writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string ¬e, const fileName &location, const word &name)
Helper: write FoamFile IOobject header.
streamFormat
Enumeration for the format of data in the stream.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void joinThread(const label)
Wait for thread.
void createThread(const label, void *(*start_routine)(void *), void *arg)
Start a thread.
compressionType
Enumeration for the format of data in the stream.
defineTypeNameAndDebug(combustionModel, 0)
const bool writeData(readBool(pdfDictionary.lookup("writeData")))
void lockMutex(const label)
Lock a mutex variable.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
label allocateThread()
Allocate a thread.
OFstreamCollator(const off_t maxBufferSize)
Construct from buffer size. 0 = do not use thread.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
prefixOSstream Pout(cout, "Pout")
void push(const T &a)
Push an element onto the stack.
label allocateMutex()
Allocate a mutex variable.
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
bool write(const word &typeName, const fileName &, const string &data, IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool append)
Write file with contents. Blocks until writethread has space.
Inter-processor communications stream.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.