Mark3 Realtime Kernel
message.h
Go to the documentation of this file.
1 /*===========================================================================
2  _____ _____ _____ _____
3  ___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
4 | \ / | || \ || | || |/ / ||___ |
5 | \/ | || \ || \ || \ ||___ |
6 |__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
7  |_____| |_____| |_____| |_____|
8 
9 --[Mark3 Realtime Platform]--------------------------------------------------
10 
11 Copyright (c) 2012 - 2019 m0slevin, all rights reserved.
12 See license.txt for more information
13 =========================================================================== */
78 #pragma once
79 
80 #include "kerneltypes.h"
81 #include "mark3cfg.h"
82 
83 #include "ll.h"
84 #include "ksemaphore.h"
85 #include "timerlist.h"
86 
87 namespace Mark3
88 {
89 //---------------------------------------------------------------------------
97 class Message : public TypedLinkListNode<Message>
98 {
99 public:
100  void* operator new(size_t sz, void* pv) { return reinterpret_cast<Message*>(pv); }
105  void Init()
106  {
107  ClearNode();
108  m_pvData = nullptr;
109  m_u16Code = 0;
110  }
111 
118  void SetData(void* pvData_) { m_pvData = pvData_; }
125  void* GetData() { return m_pvData; }
132  void SetCode(uint16_t u16Code_) { m_u16Code = u16Code_; }
139  uint16_t GetCode() { return m_u16Code; }
140 
141 private:
143  void* m_pvData;
144 
146  uint16_t m_u16Code;
147 };
148 
149 //---------------------------------------------------------------------------
158 {
159 public:
160  void* operator new(size_t sz, void* pv) { return (MessagePool*)pv; }
167  void Init();
168 
178  void Push(Message* pclMessage_);
179 
188  Message* Pop();
189 
197  Message* GetHead();
198 
199 private:
202 };
203 
204 //---------------------------------------------------------------------------
211 {
212 public:
213  void* operator new(size_t sz, void* pv) { return (MessageQueue*)pv; }
215 
221  void Init();
222 
231  Message* Receive();
232 
247  Message* Receive(uint32_t u32TimeWaitMS_);
248 
257  void Send(Message* pclSrc_);
258 
266  uint16_t GetCount();
267 
268 private:
278  Message* Receive_i(uint32_t u32TimeWaitMS_);
279 
282 
285 };
286 } // namespace Mark3
The MessagePool Class The MessagePool class implements a simple allocator for message objects exchang...
Definition: message.h:157
Semaphore Blocking Object class declarations.
Timer list declarations.
Basic data type primatives used throughout the OS.
uint16_t GetCode()
GetCode Return the code set in the message upon receipt.
Definition: message.h:139
TypedDoubleLinkList< Message > m_clList
Linked list used to manage the Message objects.
Definition: message.h:201
Semaphore m_clSemaphore
Counting semaphore used to manage thread blocking.
Definition: message.h:281
the Semaphore class provides Binary & Counting semaphore objects, based on BlockingObject base class...
Definition: ksemaphore.h:36
void Init()
Init Initialize the data and code in the message.
Definition: message.h:105
TypedDoubleLinkList< Message > m_clLinkList
List object used to store messages.
Definition: message.h:284
Definition: atomic.cpp:23
Mark3 Kernel Configuration This file is used to configure the kernel for your specific application in...
void SetCode(uint16_t u16Code_)
SetCode Set the code in the message before transmission.
Definition: message.h:132
The MessageQueue class. Implements a mechanism used to send/receive data between threads. Allows threads to block, waiting for messages to be sent from other contexts.
Definition: message.h:210
uint16_t m_u16Code
Message code, providing context for the message.
Definition: message.h:146
void * GetData()
GetData Get the data pointer stored in the message upon receipt.
Definition: message.h:125
the Message class. This object provides threadsafe message-based IPC services based on exchange of ob...
Definition: message.h:97
void * m_pvData
Pointer to the message data.
Definition: message.h:143
void SetData(void *pvData_)
SetData Set the data pointer for the message before transmission.
Definition: message.h:118
Core linked-list declarations, used by all kernel list types At the heart of RTOS data structures are...