• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef LITE_THREAD_ADAPTER_H
16 #define LITE_THREAD_ADAPTER_H
17 
18 #include <ohos_types.h>
19 #include "common.h"
20 #ifdef __cplusplus
21 #if __cplusplus
22 extern "C" {
23 #endif
24 #endif
25 
26 /// \details Mutex ID identifies the mutex.
27 typedef void *(*Runnable)(void *argv);
28 
29 typedef struct ThreadAttr ThreadAttr;
30 struct ThreadAttr {
31     const char *name;   // name of the thread
32     uint32 stackSize;   // size of stack
33     uint8 priority;     // initial thread priority
34     uint8 reserved1;    // reserved1 (must be 0)
35     uint16 reserved2;   // reserved2 (must be 0)
36 };
37 
38 MutexId MUTEX_InitValue(void);
39 
40 void MUTEX_Lock(MutexId mutex);
41 
42 void MUTEX_Unlock(MutexId mutex);
43 
44 void MUTEX_GlobalLock(void);
45 
46 void MUTEX_GlobalUnlock(void);
47 
48 ThreadId THREAD_Create(Runnable run, void *argv, const ThreadAttr *attr);
49 
50 int THREAD_Total(void);
51 
52 void *THREAD_GetThreadLocal(void);
53 
54 void THREAD_SetThreadLocal(const void *local);
55 #ifdef __cplusplus
56 #if __cplusplus
57 }
58 #endif
59 #endif
60 #endif // LITE_THREAD_ADAPTER_H
61