Compute Library
 22.05
ContextSchedulerUser Class Reference

#include <Helpers.h>

Collaboration diagram for ContextSchedulerUser:
[legend]

Public Member Functions

 ContextSchedulerUser (RuntimeContext *ctx)
 Default Constructor. More...
 
 ContextSchedulerUser (const ContextSchedulerUser &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ContextSchedulerUser (ContextSchedulerUser &&)=default
 Default move constructor. More...
 
ContextSchedulerUseroperator= (const ContextSchedulerUser &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ContextSchedulerUseroperator= (ContextSchedulerUser &&)=default
 Default move assignment operator. More...
 
void intercept_scheduler (std::unique_ptr< IScheduler > interceptor)
 Intercept the scheduler used by. More...
 
void restore_scheduler ()
 Restore the original scheduler. More...
 
ISchedulerscheduler ()
 Real scheduler accessor. More...
 
- Public Member Functions inherited from ISchedulerUser
virtual ~ISchedulerUser ()=default
 Default Destructor. More...
 

Detailed Description

Definition at line 34 of file Helpers.h.

Constructor & Destructor Documentation

◆ ContextSchedulerUser() [1/3]

Default Constructor.

Parameters
[in]ctxRuntime context to track

Definition at line 41 of file Helpers.h.

References ARM_COMPUTE_ERROR_ON, ContextSchedulerUser::operator=(), and RuntimeContext::scheduler().

42  : _ctx(ctx), _scheduler_to_use(nullptr), _real_scheduler(nullptr), _interceptor(nullptr)
43  {
44  ARM_COMPUTE_ERROR_ON(ctx == nullptr);
45  _real_scheduler = _ctx->scheduler();
46  _scheduler_to_use = _real_scheduler;
47  }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
IScheduler * scheduler() override
Scheduler accessor.

◆ ContextSchedulerUser() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ ContextSchedulerUser() [3/3]

Default move constructor.

Member Function Documentation

◆ intercept_scheduler()

void intercept_scheduler ( std::unique_ptr< IScheduler interceptor)
inlinevirtual

Intercept the scheduler used by.

Parameters
interceptorIntercept the scheduler used by the scheduler user.

Implements ISchedulerUser.

Definition at line 58 of file Helpers.h.

References RuntimeContext::set_scheduler().

59  {
60  if(interceptor != nullptr)
61  {
62  _interceptor = std::move(interceptor);
63  _scheduler_to_use = _interceptor.get();
64  _ctx->set_scheduler(_scheduler_to_use);
65  }
66  }
void set_scheduler(IScheduler *scheduler)
CPU Scheduler setter.

◆ operator=() [1/2]

ContextSchedulerUser& operator= ( const ContextSchedulerUser )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by ContextSchedulerUser::ContextSchedulerUser().

◆ operator=() [2/2]

ContextSchedulerUser& operator= ( ContextSchedulerUser &&  )
default

Default move assignment operator.

◆ restore_scheduler()

void restore_scheduler ( )
inlinevirtual

Restore the original scheduler.

Implements ISchedulerUser.

Definition at line 67 of file Helpers.h.

References RuntimeContext::set_scheduler().

68  {
69  _interceptor = nullptr;
70  _scheduler_to_use = _real_scheduler;
71  _ctx->set_scheduler(_scheduler_to_use);
72  }
void set_scheduler(IScheduler *scheduler)
CPU Scheduler setter.

◆ scheduler()

IScheduler* scheduler ( )
inlinevirtual

Real scheduler accessor.

Returns
The real scheduler

Implements ISchedulerUser.

Definition at line 73 of file Helpers.h.

74  {
75  return _real_scheduler;
76  }

The documentation for this class was generated from the following file: