EventFramework library allows the creation of an event-driven infrastructure in which small "threads" can handle events in a multithreaded execution context. The EventFramework can be configured to act as a cooperative or a fully-preemptive kernel with fixed-priority scheduling. Furthermore, this kernel matches run-to-completion semantics, and hence a single-stack configuration is enough to keep running this multithreaded execution environment. As running threads shares global stack, a huge quantity of RAM is saved in contrast with traditional RTOSes.
List/List.h@1:ec12f2e32faf, 2012-10-03 (annotated)
- Committer:
- raulMrello
- Date:
- Wed Oct 03 21:02:16 2012 +0000
- Revision:
- 1:ec12f2e32faf
- Parent:
- 0:9d09acc8f9d9
Nesting correction on RestoreContext interface.; Erase invalid comment-block
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
raulMrello | 0:9d09acc8f9d9 | 1 | /* mbed EventFramework Library |
raulMrello | 0:9d09acc8f9d9 | 2 | * Copyright (c) 2012 raulMrello |
raulMrello | 0:9d09acc8f9d9 | 3 | * |
raulMrello | 0:9d09acc8f9d9 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
raulMrello | 0:9d09acc8f9d9 | 5 | * of this software and associated documentation files (the "Software"), to deal |
raulMrello | 0:9d09acc8f9d9 | 6 | * in the Software without restriction, including without limitation the rights |
raulMrello | 0:9d09acc8f9d9 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
raulMrello | 0:9d09acc8f9d9 | 8 | * copies of the Software, and to permit persons to whom the Software is |
raulMrello | 0:9d09acc8f9d9 | 9 | * furnished to do so, subject to the following conditions: |
raulMrello | 0:9d09acc8f9d9 | 10 | * |
raulMrello | 0:9d09acc8f9d9 | 11 | * The above copyright notice and this permission notice shall be included in |
raulMrello | 0:9d09acc8f9d9 | 12 | * all copies or substantial portions of the Software. |
raulMrello | 0:9d09acc8f9d9 | 13 | * |
raulMrello | 0:9d09acc8f9d9 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
raulMrello | 0:9d09acc8f9d9 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
raulMrello | 0:9d09acc8f9d9 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
raulMrello | 0:9d09acc8f9d9 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
raulMrello | 0:9d09acc8f9d9 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
raulMrello | 0:9d09acc8f9d9 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
raulMrello | 0:9d09acc8f9d9 | 20 | * THE SOFTWARE. |
raulMrello | 0:9d09acc8f9d9 | 21 | */ |
raulMrello | 0:9d09acc8f9d9 | 22 | |
raulMrello | 0:9d09acc8f9d9 | 23 | #ifndef _LIST_H_ |
raulMrello | 0:9d09acc8f9d9 | 24 | #define _LIST_H_ |
raulMrello | 0:9d09acc8f9d9 | 25 | |
raulMrello | 0:9d09acc8f9d9 | 26 | #include "../Node/Node.h" |
raulMrello | 0:9d09acc8f9d9 | 27 | |
raulMrello | 0:9d09acc8f9d9 | 28 | /** List class |
raulMrello | 0:9d09acc8f9d9 | 29 | * |
raulMrello | 0:9d09acc8f9d9 | 30 | * List objects, can manage dual linked lists of nodes. They allow the insertion, |
raulMrello | 0:9d09acc8f9d9 | 31 | * removal of nodes at different points of the list. It is a utiliy class for the |
raulMrello | 0:9d09acc8f9d9 | 32 | * framework to manage Event and EventHandler queues. |
raulMrello | 0:9d09acc8f9d9 | 33 | * |
raulMrello | 0:9d09acc8f9d9 | 34 | */ |
raulMrello | 0:9d09acc8f9d9 | 35 | class List{ |
raulMrello | 0:9d09acc8f9d9 | 36 | public: |
raulMrello | 0:9d09acc8f9d9 | 37 | |
raulMrello | 0:9d09acc8f9d9 | 38 | /** Creates a new List with a first node, in which is attached a new data |
raulMrello | 0:9d09acc8f9d9 | 39 | * item. |
raulMrello | 0:9d09acc8f9d9 | 40 | * |
raulMrello | 0:9d09acc8f9d9 | 41 | * @param item data object to attach to the first node. |
raulMrello | 0:9d09acc8f9d9 | 42 | */ |
raulMrello | 0:9d09acc8f9d9 | 43 | List(void* item); |
raulMrello | 0:9d09acc8f9d9 | 44 | |
raulMrello | 0:9d09acc8f9d9 | 45 | ~List(); |
raulMrello | 0:9d09acc8f9d9 | 46 | |
raulMrello | 0:9d09acc8f9d9 | 47 | /** Adds a new node with a new data item, after a specified node |
raulMrello | 0:9d09acc8f9d9 | 48 | * already present in the list. |
raulMrello | 0:9d09acc8f9d9 | 49 | * |
raulMrello | 0:9d09acc8f9d9 | 50 | * @param node exisiting node in the list, previous to the new one to create. |
raulMrello | 0:9d09acc8f9d9 | 51 | * @param item data reference to attach |
raulMrello | 0:9d09acc8f9d9 | 52 | */ |
raulMrello | 0:9d09acc8f9d9 | 53 | void AddAfter(Node* node, void* item); |
raulMrello | 0:9d09acc8f9d9 | 54 | |
raulMrello | 0:9d09acc8f9d9 | 55 | /** Adds a new node with a new data item, before a specified node |
raulMrello | 0:9d09acc8f9d9 | 56 | * already present in the list. |
raulMrello | 0:9d09acc8f9d9 | 57 | * |
raulMrello | 0:9d09acc8f9d9 | 58 | * @param node exisiting node in the list, next to the new one to create. |
raulMrello | 0:9d09acc8f9d9 | 59 | * @param item data object to attach |
raulMrello | 0:9d09acc8f9d9 | 60 | * @returns 0 if the first node in the list is unchange, or a node reference |
raulMrello | 0:9d09acc8f9d9 | 61 | * pointing to the new first node in the list. |
raulMrello | 0:9d09acc8f9d9 | 62 | */ |
raulMrello | 0:9d09acc8f9d9 | 63 | Node* AddBefore(Node* node, void* item); |
raulMrello | 0:9d09acc8f9d9 | 64 | |
raulMrello | 0:9d09acc8f9d9 | 65 | /** Removes a specified node from the list. |
raulMrello | 0:9d09acc8f9d9 | 66 | * |
raulMrello | 0:9d09acc8f9d9 | 67 | * @param node exisiting node in the list, to be removed. |
raulMrello | 0:9d09acc8f9d9 | 68 | */ |
raulMrello | 0:9d09acc8f9d9 | 69 | void Remove(Node* node); |
raulMrello | 0:9d09acc8f9d9 | 70 | |
raulMrello | 0:9d09acc8f9d9 | 71 | /** Removes a specified item in one or several nodes in the list. |
raulMrello | 0:9d09acc8f9d9 | 72 | * |
raulMrello | 0:9d09acc8f9d9 | 73 | * @param item attached data object reference to remove from the list. |
raulMrello | 0:9d09acc8f9d9 | 74 | */ |
raulMrello | 0:9d09acc8f9d9 | 75 | void RemoveItem(void* item); |
raulMrello | 0:9d09acc8f9d9 | 76 | |
raulMrello | 0:9d09acc8f9d9 | 77 | /** Removes all nodes of the list. Then frees memory allocated for the list. |
raulMrello | 0:9d09acc8f9d9 | 78 | * |
raulMrello | 0:9d09acc8f9d9 | 79 | */ |
raulMrello | 0:9d09acc8f9d9 | 80 | void RemoveAll(void); |
raulMrello | 0:9d09acc8f9d9 | 81 | |
raulMrello | 0:9d09acc8f9d9 | 82 | /** Gets a reference to the first node in the list. |
raulMrello | 0:9d09acc8f9d9 | 83 | * |
raulMrello | 0:9d09acc8f9d9 | 84 | * @returns a reference to the first node in the list. |
raulMrello | 0:9d09acc8f9d9 | 85 | */ |
raulMrello | 0:9d09acc8f9d9 | 86 | Node* GetFirstNode(void); |
raulMrello | 0:9d09acc8f9d9 | 87 | |
raulMrello | 0:9d09acc8f9d9 | 88 | /** Sets the first node of the list with a node reference |
raulMrello | 0:9d09acc8f9d9 | 89 | * |
raulMrello | 0:9d09acc8f9d9 | 90 | * @param node node reference to set as first node of the list. |
raulMrello | 0:9d09acc8f9d9 | 91 | */ |
raulMrello | 0:9d09acc8f9d9 | 92 | void SetFirstNode(Node* node); |
raulMrello | 0:9d09acc8f9d9 | 93 | private: |
raulMrello | 0:9d09acc8f9d9 | 94 | Node* head; |
raulMrello | 0:9d09acc8f9d9 | 95 | }; |
raulMrello | 0:9d09acc8f9d9 | 96 | |
raulMrello | 0:9d09acc8f9d9 | 97 | #endif |