AWS IoT Device SDK C: Platform
Platform portability layer
Return to main page ↑
iot_threads.h
Go to the documentation of this file.
1 /*
2  * IoT Platform V1.1.0
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
28 #ifndef IOT_THREADS_H_
29 #define IOT_THREADS_H_
30 
31 /* The config header is always included first. */
32 #include "iot_config.h"
33 
34 /* Standard includes. */
35 #include <stdbool.h>
36 #include <stdint.h>
37 
38 /* Platform layer types include. */
40 
112 /* @[declare_platform_threads_createdetachedthread] */
113 bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
114  void * pArgument,
115  int32_t priority,
116  size_t stackSize );
117 /* @[declare_platform_threads_createdetachedthread] */
118 
148 /* @[declare_platform_threads_mutexcreate] */
149 bool IotMutex_Create( IotMutex_t * pNewMutex, bool recursive );
150 /* @[declare_platform_threads_mutexcreate] */
151 
164 /* @[declare_platform_threads_mutexdestroy] */
165 void IotMutex_Destroy( IotMutex_t * pMutex );
166 /* @[declare_platform_threads_mutexdestroy] */
167 
179 /* @[declare_platform_threads_mutexlock] */
180 void IotMutex_Lock( IotMutex_t * pMutex );
181 /* @[declare_platform_threads_mutexlock] */
182 
196 /* @[declare_platform_threads_mutextrylock] */
197 bool IotMutex_TryLock( IotMutex_t * pMutex );
198 /* @[declare_platform_threads_mutextrylock] */
199 
211 /* @[declare_platform_threads_mutexunlock] */
212 void IotMutex_Unlock( IotMutex_t * pMutex );
213 /* @[declare_platform_threads_mutexunlock] */
214 
245 /* @[declare_platform_threads_semaphorecreate] */
246 bool IotSemaphore_Create( IotSemaphore_t * pNewSemaphore,
247  uint32_t initialValue,
248  uint32_t maxValue );
249 /* @[declare_platform_threads_semaphorecreate] */
250 
263 /* @[declare_platform_threads_semaphoredestroy] */
264 void IotSemaphore_Destroy( IotSemaphore_t * pSemaphore );
265 /* @[declare_platform_threads_semaphoredestroy] */
266 
277 /* @[declare_platform_threads_semaphoregetcount] */
278 uint32_t IotSemaphore_GetCount( IotSemaphore_t * pSemaphore );
279 /* @[declare_platform_threads_semaphoregetcount] */
280 
294 /* @[declare_platform_threads_semaphorewait] */
295 void IotSemaphore_Wait( IotSemaphore_t * pSemaphore );
296 /* @[declare_platform_threads_semaphorewait] */
297 
314 /* @[declare_platform_threads_semaphoretrywait] */
315 bool IotSemaphore_TryWait( IotSemaphore_t * pSemaphore );
316 /* @[declare_platform_threads_semaphoretrywait] */
317 
336 /* @[declare_platform_threads_semaphoretimedwait] */
337 bool IotSemaphore_TimedWait( IotSemaphore_t * pSemaphore,
338  uint32_t timeoutMs );
339 /* @[declare_platform_threads_semaphoretimedwait] */
340 
350 /* @[declare_platform_threads_semaphorepost] */
351 void IotSemaphore_Post( IotSemaphore_t * pSemaphore );
352 /* @[declare_platform_threads_semaphorepost] */
353 
354 #endif /* ifndef IOT_THREADS_H_ */
bool Iot_CreateDetachedThread(IotThreadRoutine_t threadRoutine, void *pArgument, int32_t priority, size_t stackSize)
Create a new detached thread, i.e. a thread that cleans up after itself.
Types of the platform layer.
bool IotMutex_Create(IotMutex_t *pNewMutex, bool recursive)
Create a new mutex.
void IotSemaphore_Post(IotSemaphore_t *pSemaphore)
Post to (unlock) a semaphore. This function should only return when the semaphore post succeeds; it i...
void IotSemaphore_Destroy(IotSemaphore_t *pSemaphore)
Free resources used by a semaphore.
bool IotSemaphore_Create(IotSemaphore_t *pNewSemaphore, uint32_t initialValue, uint32_t maxValue)
Create a new counting semaphore.
uint32_t IotSemaphore_GetCount(IotSemaphore_t *pSemaphore)
Query the current count of the semaphore.
bool IotSemaphore_TimedWait(IotSemaphore_t *pSemaphore, uint32_t timeoutMs)
Attempt to wait on (lock) a semaphore with a timeout.
_IotSystemSemaphore_t IotSemaphore_t
The type used to represent semaphores, configured with the type _IotSystemSemaphore_t.
Definition: iot_platform_types.h:102
bool IotMutex_TryLock(IotMutex_t *pMutex)
Attempt to lock a mutex. Return immediately if the mutex is not available.
void IotMutex_Lock(IotMutex_t *pMutex)
Lock a mutex. This function should only return when the mutex is locked; it is not expected to fail...
_IotSystemMutex_t IotMutex_t
The type used to represent mutexes, configured with the type _IotSystemMutex_t.
Definition: iot_platform_types.h:82
void(* IotThreadRoutine_t)(void *pArgument)
Thread routine function.
Definition: iot_platform_types.h:110
void IotMutex_Unlock(IotMutex_t *pMutex)
Unlock a mutex. This function should only return when the mutex is unlocked; it is not expected to fa...
void IotSemaphore_Wait(IotSemaphore_t *pSemaphore)
Wait on (lock) a semaphore. This function should only return when the semaphore wait succeeds; it is ...
void IotMutex_Destroy(IotMutex_t *pMutex)
Free resources used by a mutex.
bool IotSemaphore_TryWait(IotSemaphore_t *pSemaphore)
Attempt to wait on (lock) a semaphore. Return immediately if the semaphore is not available...