@@ -318,8 +318,7 @@ void GlobalHandler::drainThreadPool() {
318318// 2) when process is being terminated
319319void shutdown_early (bool CanJoinThreads = true ) {
320320 const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
321- GlobalHandler *&Handler = GlobalHandler::getInstancePtr ();
322- if (!Handler)
321+ if (!GlobalHandler::RTGlobalObjHandler)
323322 return ;
324323
325324#if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32)
@@ -329,26 +328,26 @@ void shutdown_early(bool CanJoinThreads = true) {
329328#endif
330329
331330 // Now that we are shutting down, we will no longer defer MemObj releases.
332- Handler ->endDeferredRelease ();
331+ GlobalHandler::RTGlobalObjHandler ->endDeferredRelease ();
333332
334333 // Ensure neither host task is working so that no default context is accessed
335334 // upon its release
336- Handler ->prepareSchedulerToRelease (true );
335+ GlobalHandler::RTGlobalObjHandler ->prepareSchedulerToRelease (true );
337336
338- if (Handler->MHostTaskThreadPool .Inst ) {
339- Handler->MHostTaskThreadPool .Inst ->finishAndWait (CanJoinThreads);
340- Handler->MHostTaskThreadPool .Inst .reset (nullptr );
337+ if (GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool .Inst ) {
338+ GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool .Inst ->finishAndWait (
339+ CanJoinThreads);
340+ GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool .Inst .reset (nullptr );
341341 }
342342
343343 // This releases OUR reference to the default context, but
344344 // other may yet have refs
345- Handler ->releaseDefaultContexts ();
345+ GlobalHandler::RTGlobalObjHandler ->releaseDefaultContexts ();
346346}
347347
348348void shutdown_late () {
349349 const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
350- GlobalHandler *&Handler = GlobalHandler::getInstancePtr ();
351- if (!Handler)
350+ if (!GlobalHandler::RTGlobalObjHandler)
352351 return ;
353352
354353#if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32)
@@ -358,26 +357,27 @@ void shutdown_late() {
358357#endif
359358
360359 // First, release resources, that may access adapters.
361- Handler ->MPlatformCache .Inst .reset (nullptr );
362- Handler ->MScheduler .Inst .reset (nullptr );
363- Handler ->MProgramManager .Inst .reset (nullptr );
360+ GlobalHandler::RTGlobalObjHandler ->MPlatformCache .Inst .reset (nullptr );
361+ GlobalHandler::RTGlobalObjHandler ->MScheduler .Inst .reset (nullptr );
362+ GlobalHandler::RTGlobalObjHandler ->MProgramManager .Inst .reset (nullptr );
364363
365364#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
366365 // Kernel cache, which is part of device kernel info,
367366 // stores handles to the adapter, so clear it before releasing adapters.
368- Handler->MDeviceKernelInfoStorage .Inst .reset (nullptr );
367+ GlobalHandler::RTGlobalObjHandler->MDeviceKernelInfoStorage .Inst .reset (
368+ nullptr );
369369#endif
370370
371371 // Clear the adapters and reset the instance if it was there.
372- Handler ->unloadAdapters ();
373- if (Handler ->MAdapters .Inst )
374- Handler ->MAdapters .Inst .reset (nullptr );
372+ GlobalHandler::RTGlobalObjHandler ->unloadAdapters ();
373+ if (GlobalHandler::RTGlobalObjHandler ->MAdapters .Inst )
374+ GlobalHandler::RTGlobalObjHandler ->MAdapters .Inst .reset (nullptr );
375375
376- Handler ->MXPTIRegistry .Inst .reset (nullptr );
376+ GlobalHandler::RTGlobalObjHandler ->MXPTIRegistry .Inst .reset (nullptr );
377377
378378 // Release the rest of global resources.
379- delete Handler ;
380- Handler = nullptr ;
379+ delete GlobalHandler::RTGlobalObjHandler ;
380+ GlobalHandler::RTGlobalObjHandler = nullptr ;
381381}
382382
383383#ifdef _WIN32
0 commit comments