Azure IoT / azure_c_shared_utility

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Committer:
AzureIoTClient
Date:
Thu Oct 04 09:17:16 2018 -0700
Revision:
49:6bb8b9a66642
Parent:
48:81866008bba4
1.2.10

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Azure.IoT Build 0:fa2de1b79154 1 // Copyright (c) Microsoft. All rights reserved.
Azure.IoT Build 0:fa2de1b79154 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
Azure.IoT Build 0:fa2de1b79154 3
Azure.IoT Build 0:fa2de1b79154 4 #ifndef CONDITION_H
Azure.IoT Build 0:fa2de1b79154 5 #define CONDITION_H
Azure.IoT Build 0:fa2de1b79154 6
Azure.IoT Build 0:fa2de1b79154 7 #include "azure_c_shared_utility/macro_utils.h"
Azure.IoT Build 0:fa2de1b79154 8 #include "azure_c_shared_utility/lock.h"
AzureIoTClient 2:20b88da3e604 9 #include "azure_c_shared_utility/umock_c_prod.h"
Azure.IoT Build 0:fa2de1b79154 10
Azure.IoT Build 0:fa2de1b79154 11 #ifdef __cplusplus
Azure.IoT Build 0:fa2de1b79154 12 extern "C" {
Azure.IoT Build 0:fa2de1b79154 13 #endif
Azure.IoT Build 0:fa2de1b79154 14
Azure.IoT Build 0:fa2de1b79154 15 typedef void* COND_HANDLE;
Azure.IoT Build 0:fa2de1b79154 16
Azure.IoT Build 0:fa2de1b79154 17 #define COND_RESULT_VALUES \
Azure.IoT Build 0:fa2de1b79154 18 COND_OK, \
Azure.IoT Build 0:fa2de1b79154 19 COND_INVALID_ARG, \
Azure.IoT Build 0:fa2de1b79154 20 COND_ERROR, \
Azure.IoT Build 0:fa2de1b79154 21 COND_TIMEOUT \
Azure.IoT Build 0:fa2de1b79154 22
Azure.IoT Build 0:fa2de1b79154 23 /**
Azure.IoT Build 0:fa2de1b79154 24 * @brief Enumeration specifying the lock status.
Azure.IoT Build 0:fa2de1b79154 25 */
Azure.IoT Build 0:fa2de1b79154 26 DEFINE_ENUM(COND_RESULT, COND_RESULT_VALUES);
Azure.IoT Build 0:fa2de1b79154 27
Azure.IoT Build 0:fa2de1b79154 28 /**
AzureIoTClient 48:81866008bba4 29 * @brief This API creates and returns a valid condition handle.
Azure.IoT Build 0:fa2de1b79154 30 *
AzureIoTClient 48:81866008bba4 31 * @return A valid @c COND_HANDLE when successful or @c NULL otherwise.
Azure.IoT Build 0:fa2de1b79154 32 */
AzureIoTClient 2:20b88da3e604 33 MOCKABLE_FUNCTION(, COND_HANDLE, Condition_Init);
Azure.IoT Build 0:fa2de1b79154 34
Azure.IoT Build 0:fa2de1b79154 35 /**
AzureIoTClient 48:81866008bba4 36 * @brief unblock all currently working condition.
Azure.IoT Build 0:fa2de1b79154 37 *
AzureIoTClient 48:81866008bba4 38 * @param handle A valid handle to the lock.
Azure.IoT Build 0:fa2de1b79154 39 *
AzureIoTClient 48:81866008bba4 40 * @return Returns @c COND_OK when the condition object has been
AzureIoTClient 48:81866008bba4 41 * destroyed and @c COND_ERROR when an error occurs
AzureIoTClient 48:81866008bba4 42 * and @c COND_TIMEOUT when the handle times out.
Azure.IoT Build 0:fa2de1b79154 43 */
AzureIoTClient 2:20b88da3e604 44 MOCKABLE_FUNCTION(, COND_RESULT, Condition_Post, COND_HANDLE, handle);
Azure.IoT Build 0:fa2de1b79154 45
Azure.IoT Build 0:fa2de1b79154 46 /**
AzureIoTClient 48:81866008bba4 47 * @brief block on the condition handle unti the thread is signalled
Azure.IoT Build 0:fa2de1b79154 48 * or until the timeout_milliseconds is reached.
Azure.IoT Build 0:fa2de1b79154 49 *
AzureIoTClient 48:81866008bba4 50 * @param handle A valid handle to the lock.
Azure.IoT Build 0:fa2de1b79154 51 *
AzureIoTClient 48:81866008bba4 52 * @return Returns @c COND_OK when the condition object has been
AzureIoTClient 48:81866008bba4 53 * destroyed and @c COND_ERROR when an error occurs
AzureIoTClient 48:81866008bba4 54 * and @c COND_TIMEOUT when the handle times out.
Azure.IoT Build 0:fa2de1b79154 55 */
AzureIoTClient 2:20b88da3e604 56 MOCKABLE_FUNCTION(, COND_RESULT, Condition_Wait, COND_HANDLE, handle, LOCK_HANDLE, lock, int, timeout_milliseconds);
Azure.IoT Build 0:fa2de1b79154 57
Azure.IoT Build 0:fa2de1b79154 58 /**
AzureIoTClient 48:81866008bba4 59 * @brief The condition instance is deinitialized.
Azure.IoT Build 0:fa2de1b79154 60 *
AzureIoTClient 48:81866008bba4 61 * @param handle A valid handle to the condition.
Azure.IoT Build 0:fa2de1b79154 62 *
AzureIoTClient 48:81866008bba4 63 * @return Returns @c COND_OK when the condition object has been
AzureIoTClient 48:81866008bba4 64 * destroyed and @c COND_ERROR when an error occurs.
Azure.IoT Build 0:fa2de1b79154 65 */
AzureIoTClient 2:20b88da3e604 66 MOCKABLE_FUNCTION(, void, Condition_Deinit, COND_HANDLE, handle);
Azure.IoT Build 0:fa2de1b79154 67
Azure.IoT Build 0:fa2de1b79154 68 #ifdef __cplusplus
Azure.IoT Build 0:fa2de1b79154 69 }
Azure.IoT Build 0:fa2de1b79154 70 #endif
Azure.IoT Build 0:fa2de1b79154 71
AzureIoTClient 2:20b88da3e604 72 #endif /* CONDITION_H */