mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 17:13:29 +08:00
Calling virtual functions from within constructors is incorrect, the virtualization mechanism does not work until a constructor completes. So, instead of performing many operations in constructors, make them small and use static `create()` methods to construct the object properly and only then perform additional setup. Mocks are a prominent example how such practice degrades the code. A function called from a constructor is basically unmockable. Despite being overriden by derived type (to alter the execution path as per needs of a given test-case) the parent versions are always called. This was making test development more and more painful as at some point there is no hack to compensate for the lack of standard mechanism. Related-To: NEO-9754 Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>