In some cases, the interface being queried may be persistently nullptr
(e.g. a gem isn't active, or a feature was disabled by a cvar). In this
case, querying the interface would always enter the writer-lock branch
with existing code because nullptr was synonmous with "we haven't
queried for this variable yet."
This PR adds an additional state variable that is set when s_instance is
assigned to, so that after the variable is queried and found to be null,
future queries can enter the read-lock branch.
Signed-off-by: Jeremy Ong <jcong@amazon.com>
AZ_Assert(false,"Interface '%s' not registered on this module!",AzTypeInfo<T>::Name());
return;
}
if(s_instance.Get()!=type)
if(s_instance&&s_instance.Get()!=type)
{
AZ_Assert(false,"Interface '%s' is not the same instance that was registered! [Expected '%p', Found '%p']",AzTypeInfo<T>::Name(),type,s_instance.Get());