]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - components/common/inc/threads.h
Updated Sensor To Cloud design to have an easy to use setup GUI on the
[apps/tidep0084.git] / components / common / inc / threads.h
1 /******************************************************************************
2  @file threads.h
4  @brief TIMAC 2.0 API generic thread abstraction header
6  Group: WCS LPC
7  $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350$
9  ******************************************************************************
10  $License: BSD3 2016 $
11   
12    Copyright (c) 2015, Texas Instruments Incorporated
13    All rights reserved.
14   
15    Redistribution and use in source and binary forms, with or without
16    modification, are permitted provided that the following conditions
17    are met:
18   
19    *  Redistributions of source code must retain the above copyright
20       notice, this list of conditions and the following disclaimer.
21   
22    *  Redistributions in binary form must reproduce the above copyright
23       notice, this list of conditions and the following disclaimer in the
24       documentation and/or other materials provided with the distribution.
25   
26    *  Neither the name of Texas Instruments Incorporated nor the names of
27       its contributors may be used to endorse or promote products derived
28       from this software without specific prior written permission.
29   
30    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37    OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  ******************************************************************************
42  $Release Name: TI-15.4Stack Linux x64 SDK$
43  $Release Date: Jun 28, 2017 (2.02.00.03)$
44  *****************************************************************************/
46 #if !defined(THREADS_H)
47 #define THREADS_H
49 #include "bitsnbits.h"
50 #include <stdint.h>
51 #include <stdbool.h>
53 /*!
54  * @typedef thread_func_t - thread function
55  * @param cookie - a parameter for the thread function
56  * @return a thread exit value can be integer or pointer
57  */
58 typedef intptr_t threadfunc_t(intptr_t cookie);
60 #define THREAD_FLAGS_DEFAULT  0 /*! default flags when creating a thread */
61 #define THREAD_FLAGS_JOINABLE _bit0 /*! make the thread joinable */
63 /*!
64  * @brief Create a thread
65  *
66  * @param name - the name of the thread
67  * @param func - the thread function
68  * @param cookie - parameter for the thread function
69  * @param startflags - see THREAD_FLAGS_*
70  *
71  * @return a thread handle for use with other functions, 0 means failure
72  *
73  * Note: The thread may be running before this thread returns.
74  */
75 intptr_t THREAD_create(const char *name, threadfunc_t *func, intptr_t cookie, int startflags);
77 /*
78  * @brief Kill/Destroy this thread
79  * @param h - thread handle
80  */
81 void THREAD_destroy(intptr_t h);
83 /*!
84  * @brief return the thread ID of the current thread
85  * @returns thread ID of current thread
86  */
87 intptr_t THREAD_self(void);
89 /*!
90  * @brief Exit the current thread with specified code
91  * @param exit_code - the code to exit with
92  */
93 void     THREAD_exit(intptr_t exit_code);
95 /*!
96  * @brief Is this thread alive (running) or has it exited?
97  * @param - thread ID
98  */
99 bool     THREAD_isAlive(intptr_t h);
101 /*!
102  * @brief Get the exit code of a thread
103  * @param - thread id to get exit code of
104  * @return value - the thread exit code if the thread has exited
105  */
106 intptr_t THREAD_getExitValue(intptr_t h);
108 /*!
109  * @brief Get debug name of this thread
110  * @param h - thread handle
111  * @return a printable string for a thread name
112  */
113 const char *THREAD_name(intptr_t h);
115 /*!
116  * @brief Get debug name of current active thread
117  * @return - name of currently active thread
118  */
119 const char *THREAD_selfName(void);
121 #endif
123 /*
124  *  ========================================
125  *  Texas Instruments Micro Controller Style
126  *  ========================================
127  *  Local Variables:
128  *  mode: c
129  *  c-file-style: "bsd"
130  *  tab-width: 4
131  *  c-basic-offset: 4
132  *  indent-tabs-mode: nil
133  *  End:
134  *  vim:set  filetype=c tabstop=4 shiftwidth=4 expandtab=true
135  */