in csharp/EPAM.Deltix.HdTime/Formatters.cs [516:546]
protected Template GetCachedOrNewTemplate(String fmt, Dictionary<String, Template> local)
{
Template f = null;
Dictionary<String, Template> global = globalTemplateCache;
// Try to find in the global formatter cache
lock (global)
{
if (global.ContainsKey(fmt))
f = global[fmt];
}
if (null == f)
{
builder.Clear();
ParseFormat(fmt);
f = builder.Get();
lock(global)
{
if (!global.ContainsKey(fmt))
global.Add(fmt, f);
else
f = global[fmt];
}
Debug.Assert(null != f);
}
// Copy the reference to local cache
local.Add(fmt, f);
return f;
}