GM6000 Digital Heater Controller Branch: main
SDX-1330
Thread.h
Go to the documentation of this file.
1#ifndef Cpl_System_BareMetal_Thread_h_
2#define Cpl_System_BareMetal_Thread_h_
3/*-----------------------------------------------------------------------------
4* This file is part of the Colony.Core Project. The Colony.Core Project is an
5* open source project with a BSD type of licensing agreement. See the license
6* agreement (license.txt) in the top/ directory or on the Internet at
7* http://integerfox.com/colony.core/license.txt
8*
9* Copyright (c) 2014-2022 John T. Taylor
10*
11* Redistributions of the source code must retain the above copyright notice.
12*----------------------------------------------------------------------------*/
13/** @file */
14
15#include "Cpl/System/Thread.h"
17#include "Cpl/Text/FString.h"
18
19
20
21///
22namespace Cpl {
23///
24namespace System {
25///
26namespace BareMetal {
27
28/** This concrete class implements 'enough' of a Thread object to support
29 Cpl::System framework on a bare metal system (a system that has only
30 ONE thread and potentially ISR contexts).
31 */
33{
34protected:
35 /// Reference to the runnable object for the thread
37
38 /// The thread synchronized message semaphore.
40
41
42public:
43 /** This method allows the application to set the Runnable object for
44 for single-thread/execution context. The method returns a reference
45 to the previous/runnable object being 'replaced'
46 */
47 static Runnable& setRunnable( Runnable& newRunnableInstance );
48
49private:
50 /// Private Constructor -->the application can not create threads!
51 Thread( Runnable& runnable, const char* name );
52
53 /// Private Constructor -->the application can not create threads!
54 Thread();
55
56 /// Private Constructor -->the application can not create threads!
57 Thread( Thread& copy );
58
59public:
60 /// Destructor
62
63public:
64 /// See Cpl::System::Thread
65 const char* getName() noexcept;
66
67 /// See Cpl::System::Thread
68 size_t getId() noexcept;
69
70 /// See Cpl::System::Thread
71 bool isRunning( void ) noexcept;
72
73 /// See Cpl::System::Thread
75
76 /// See Cpl::System::Thread
77 Runnable& getRunnable( void ) noexcept;
78
79
80public:
81 /// See Cpl::System::Signable
82 int signal( void ) noexcept;
83
84 /// See Cpl::System::Signable
85 int su_signal( void ) noexcept;
86
87
88
89
90public:
91 /** COMPONENT Scoped constructor to "convert" the current execution context
92 to a Cpl Thread. THIS CONSTRUCTOR SHOULD NEVER BE USED BY THE APPLICATION!
93 */
94 Thread( Cpl::System::Runnable& dummyRunnable );
95
96
97public:
98 /// Housekeeping
99 friend class Cpl::System::Thread;
100};
101
102
103}; // end namespaces
104};
105};
106#endif // end header latch
#define Cpl_System_Thread_NativeHdl_T
Defer the definition of the native thread handle to the application's 'platform'.
Definition Thread.h:23
This concrete class implements 'enough' of a Thread object to support Cpl::System framework on a bare...
Definition Thread.h:33
int signal(void) noexcept
See Cpl::System::Signable.
Runnable & getRunnable(void) noexcept
See Cpl::System::Thread.
int su_signal(void) noexcept
See Cpl::System::Signable.
bool isRunning(void) noexcept
See Cpl::System::Thread.
static Runnable & setRunnable(Runnable &newRunnableInstance)
This method allows the application to set the Runnable object for for single-thread/execution context...
Cpl::System::Runnable * m_runnable
Reference to the runnable object for the thread.
Definition Thread.h:36
friend class Cpl::System::Thread
Housekeeping.
Definition Thread.h:99
const char * getName() noexcept
See Cpl::System::Thread.
Cpl_System_Thread_NativeHdl_T getNativeHandle(void) noexcept
See Cpl::System::Thread.
Cpl::System::Semaphore m_syncSema
The thread synchronized message semaphore.
Definition Thread.h:39
size_t getId() noexcept
See Cpl::System::Thread.
This is an abstract class defines the interface for an object that is "executed" when a Thread object...
Definition Runnable.h:29
This semaphore class defines the interface for a Counting Semaphore.
Definition Semaphore.h:37
This abstract class defines the operations that can be performed on a thread.
Definition Thread.h:62
The 'Cpl' namespace is the root name space for the Colony.
Definition Api16.h:20