async_select  2.0.2
async_select
async_select_osal.c
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2017-2020 MicroEJ Corp. All rights reserved.
5  * This library is provided in source code for use, modification and test, subject to license terms.
6  * Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
7  */
8 
17 #include "async_select.h"
19 #include "osal.h"
20 #include <stddef.h>
21 
22 #ifdef __cplusplus
23  extern "C" {
24 #endif
25 
31 extern void async_select_request_fifo_init(void);
36 extern void async_select_task_main(void);
37 
38 /*
39  * See implementations for descriptions.
40  */
41 void async_select_lock(void);
42 void async_select_unlock(void);
43 static int32_t async_select_start_task(void);
44 
52 static OSAL_task_handle_t async_select_task;
56 static OSAL_mutex_handle_t async_select_mutex;
57 
65  int32_t res;
66  res = async_select_start_task();
67  if(res == 0){
69  }
70  return res;
71 }
72 
76 static int32_t async_select_start_task(){
77  OSAL_status_t status;
78 
79  status = OSAL_mutex_create(ASYNC_SELECT_MUTEX_NAME, &async_select_mutex);
80 
81  if(status == OSAL_OK){
82  status = OSAL_task_create((OSAL_task_entry_point_t) async_select_task_main, ASYNC_SELECT_TASK_NAME, async_select_task_stack, ASYNC_SELECT_TASK_PRIORITY, NULL, &async_select_task);
83  }
84 
85  if(status == OSAL_OK){
86  return 0;
87  }
88  else{
89  return -1;
90  }
91 }
92 
96 void async_select_lock(void){
97  OSAL_mutex_take(&async_select_mutex, OSAL_INFINITE_TIME);
98 }
99 
104  OSAL_mutex_give(&async_select_mutex);
105 }
106 
107 #ifdef __cplusplus
108  }
109 #endif
OSAL_task_stack_declare(async_select_task_stack, ASYNC_SELECT_TASK_STACK_SIZE)
Stack of the async_select task.
int32_t async_select_init()
Initialize the async_select component. This function must be called prior to any call of async_select...
void async_select_unlock(void)
Exit critical section for the async_select component.
#define ASYNC_SELECT_MUTEX_NAME
async_select mutex name.
#define ASYNC_SELECT_TASK_NAME
async_select task name.
void async_select_lock(void)
Enter critical section for the async_select component.
Asynchronous network select configuration.
void async_select_task_main(void)
The entry point for the async_select task. This function must be called from a dedicated task...
Definition: async_select.c:267
Asynchronous network select API.
void async_select_request_fifo_init(void)
Initializes the requests FIFOs. This function must be called prior to any call of async_select()...
Definition: async_select.c:213
#define ASYNC_SELECT_TASK_PRIORITY
async_select task priority.
#define ASYNC_SELECT_TASK_STACK_SIZE
async_select task stack size in bytes.