mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
fileModification: time checking now with nano-second precision
fileModificationSkew: now a floating-point number to support sub-second specification. Patch contributed by Mattijs Janssens
This commit is contained in:
@ -523,6 +523,22 @@ time_t Foam::lastModified(const fileName& name)
|
||||
}
|
||||
|
||||
|
||||
double Foam::highResLastModified(const fileName& name)
|
||||
{
|
||||
fileStat fileStatus(name);
|
||||
if (fileStatus.isValid())
|
||||
{
|
||||
return
|
||||
fileStatus.status().st_mtime
|
||||
+ 1e-9d*fileStatus.status().st_atim.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::fileNameList Foam::readDir
|
||||
(
|
||||
const fileName& directory,
|
||||
|
||||
@ -126,7 +126,7 @@ namespace Foam
|
||||
// For stat
|
||||
|
||||
//- From watch descriptor to modified time
|
||||
DynamicList<time_t> lastMod_;
|
||||
DynamicList<double> lastMod_;
|
||||
|
||||
|
||||
|
||||
@ -261,7 +261,7 @@ namespace Foam
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
lastMod_(watchFd) = lastModified(fName);
|
||||
lastMod_(watchFd) = highResLastModified(fName);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -395,12 +395,12 @@ void Foam::fileMonitor::checkFiles() const
|
||||
{
|
||||
forAll(watcher_->lastMod_, watchFd)
|
||||
{
|
||||
time_t oldTime = watcher_->lastMod_[watchFd];
|
||||
double oldTime = watcher_->lastMod_[watchFd];
|
||||
|
||||
if (oldTime != 0)
|
||||
{
|
||||
const fileName& fName = watchFile_[watchFd];
|
||||
time_t newTime = lastModified(fName);
|
||||
double newTime = highResLastModified(fName);
|
||||
|
||||
if (newTime == 0)
|
||||
{
|
||||
@ -615,7 +615,7 @@ void Foam::fileMonitor::setUnmodified(const label watchFd)
|
||||
|
||||
if (!useInotify_)
|
||||
{
|
||||
watcher_->lastMod_[watchFd] = lastModified(watchFile_[watchFd]);
|
||||
watcher_->lastMod_[watchFd] = highResLastModified(watchFile_[watchFd]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,14 +48,14 @@ namespace Foam
|
||||
};
|
||||
}
|
||||
|
||||
int Foam::regIOobject::fileModificationSkew
|
||||
float Foam::regIOobject::fileModificationSkew
|
||||
(
|
||||
Foam::debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
Foam::debug::floatOptimisationSwitch("fileModificationSkew", 30)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"fileModificationSkew",
|
||||
int,
|
||||
float,
|
||||
Foam::regIOobject::fileModificationSkew
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -124,7 +124,7 @@ public:
|
||||
//- Runtime type information
|
||||
TypeName("regIOobject");
|
||||
|
||||
static int fileModificationSkew;
|
||||
static float fileModificationSkew;
|
||||
|
||||
static fileCheckTypes fileModificationChecking;
|
||||
|
||||
|
||||
@ -872,8 +872,23 @@ void Foam::argList::parse
|
||||
<< regIOobject::fileCheckTypesNames
|
||||
[
|
||||
regIOobject::fileModificationChecking
|
||||
]
|
||||
<< endl;
|
||||
];
|
||||
if
|
||||
(
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::timeStamp
|
||||
)
|
||||
|| (
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::timeStampMaster
|
||||
)
|
||||
)
|
||||
{
|
||||
Info<< " (fileModificationSkew "
|
||||
<< regIOobject::fileModificationSkew << ")";
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
Info<< "allowSystemOperations : ";
|
||||
if (dynamicCode::allowSystemOperations)
|
||||
|
||||
@ -190,6 +190,19 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
|
||||
}
|
||||
|
||||
|
||||
float Foam::debug::floatOptimisationSwitch
|
||||
(
|
||||
const char* name,
|
||||
const float defaultValue
|
||||
)
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = debugObjects().lookupPtr(name);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -74,6 +74,13 @@ namespace debug
|
||||
//- Lookup optimisation switch or add default value.
|
||||
int optimisationSwitch(const char* name, const int defaultValue=0);
|
||||
|
||||
//- Lookup optimisation switch or add default value.
|
||||
float floatOptimisationSwitch
|
||||
(
|
||||
const char* name,
|
||||
const float defaultValue=0
|
||||
);
|
||||
|
||||
//- Internal function to lookup a sub-dictionary from controlDict.
|
||||
dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr);
|
||||
|
||||
|
||||
@ -122,6 +122,9 @@ off_t fileSize(const fileName&);
|
||||
//- Return time of last file modification
|
||||
time_t lastModified(const fileName&);
|
||||
|
||||
//- Return time of last file modification
|
||||
double highResLastModified(const fileName&);
|
||||
|
||||
//- Read a directory and return the entries as a string list
|
||||
fileNameList readDir
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user