protected function lock()
{
if (self::$lock) {
throw new LogicException('Critical section has already beed entered.');
}
$file = realpath(sys_get_temp_dir()) . '/NextrasOrmArrayMapper.lock.' . md5(__FILE__);
$handle = fopen($file, 'c+');
if (!$handle) {
throw new IOException('Unable to create critical section.');
}
flock($handle, LOCK_EX);
self::$lock = $handle;
}