mn::system::basic_schedular_lock Class Reference

#include <mn_schedular_lock.hpp>

+ Inheritance diagram for mn::system::basic_schedular_lock:
+ Collaboration diagram for mn::system::basic_schedular_lock:

Public Member Functions

int lock (unsigned int timeout=0)
 
int unlock ()
 
- Public Member Functions inherited from mn::system::ISystemLockObject
virtual int time_lock (const struct timespec *timeout)
 
virtual bool is_initialized ()
 
- Public Member Functions inherited from mn::ILockObject
 ILockObject ()
 
virtual bool try_lock ()
 
virtual bool is_initialized () const =0
 
virtual bool is_locked () const =0
 Is locked? More...
 

Additional Inherited Members

- Public Types inherited from mn::ILockObject
using this_type = ILockObject
 

Detailed Description

This class is a lock helper for disable and enable the schedular with auto_schedular_lock_t guard Example usage:

void* foo_task::on_task() {
basic_schedular_lock scheL;
for(;;) {
// Prevent the real time kernel swapping out the task.
scheL.lock();
// Perform the operation here. There is no need to use critical
// sections as we have all the microcontroller processing time.
// During this time interrupts will still operate and the real
// time kernel tick count will be maintained.
// ...
// The operation is complete. Restart the kernel. We want to force
// a context switch - but there is no point if resuming the scheduler
// caused a context switch already.
if( scheL.unlock() () ) {
}
}
}
static void yield()
Yield the scheduler.
Definition: mn_task.hpp:371

Member Function Documentation

◆ lock()

int mn::system::basic_schedular_lock::lock ( unsigned int  timeout = 0)
virtual

Disable the schedular

Returns
- ERR_SYSTEM_NO_RETURN no errors

Implements mn::ILockObject.

◆ unlock()

int mn::system::basic_schedular_lock::unlock ( )
virtual

Enable the schedular

Returns
If resuming the scheduler caused a context switch then ERR_SYSTEM_OK is returned, otherwise ERR_SYSTEM_UNLOCK is returned.

Implements mn::ILockObject.


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