Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
task.h
00001 /****************************************************************************** 00002 The MIT License(MIT) 00003 00004 Embedded Template Library. 00005 https://github.com/ETLCPP/etl 00006 http://www.etlcpp.com 00007 00008 Copyright(c) 2017 jwellbelove 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy 00011 of this software and associated documentation files(the "Software"), to deal 00012 in the Software without restriction, including without limitation the rights 00013 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00014 copies of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions : 00016 00017 The above copyright notice and this permission notice shall be included in all 00018 copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00026 SOFTWARE. 00027 ******************************************************************************/ 00028 00029 #ifndef __ETL_TASK__ 00030 #define __ETL_TASK__ 00031 00032 #include <stdint.h> 00033 00034 #include "platform.h " 00035 #include "error_handler.h " 00036 #include "exception.h " 00037 00038 #undef ETL_FILE 00039 #define ETL_FILE "37" 00040 00041 namespace etl 00042 { 00043 //*************************************************************************** 00044 /// Base exception class for task. 00045 //*************************************************************************** 00046 class task_exception : public etl::exception 00047 { 00048 public: 00049 00050 task_exception(string_type reason_, string_type file_name_, numeric_type line_number_) 00051 : etl::exception(reason_, file_name_, line_number_) 00052 { 00053 } 00054 }; 00055 00056 typedef uint_least8_t task_priority_t; 00057 00058 //*************************************************************************** 00059 /// Scheduler. 00060 //*************************************************************************** 00061 class task 00062 { 00063 public: 00064 00065 //******************************************* 00066 /// Constructor. 00067 //******************************************* 00068 task(task_priority_t priority) 00069 : task_running(true), 00070 task_priority(priority) 00071 { 00072 } 00073 00074 //******************************************* 00075 /// Destructor. 00076 //******************************************* 00077 virtual ~task() 00078 { 00079 } 00080 00081 //******************************************* 00082 /// Called to check if the task has work. 00083 /// Returns a score as to the amount of work it has to do. 00084 //******************************************* 00085 virtual uint32_t task_request_work() const = 0; 00086 00087 //******************************************* 00088 /// Called to get the task to do work. 00089 //******************************************* 00090 virtual void task_process_work() = 0; 00091 00092 //******************************************* 00093 /// Set the running state for the task. 00094 //******************************************* 00095 void set_task_running(bool task_running_) 00096 { 00097 task_running = task_running_; 00098 } 00099 00100 //******************************************* 00101 /// Get the running state for the task. 00102 //******************************************* 00103 bool task_is_running() const 00104 { 00105 return task_running; 00106 } 00107 00108 //******************************************* 00109 /// Get the priority of the task. 00110 /// Higher value = higher priority. 00111 //******************************************* 00112 etl::task_priority_t get_task_priority() const 00113 { 00114 return task_priority; 00115 } 00116 00117 private: 00118 00119 bool task_running; 00120 etl::task_priority_t task_priority; 00121 }; 00122 } 00123 00124 #undef ETL_FILE 00125 00126 #endif 00127
Generated on Tue Jul 12 2022 14:05:44 by
