| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include "wanning.h"
- #include "fifo.h"
- #include "pthread.h"
- #include "rtthread.h"
- typedef struct {
- GenericFixedList *list;
- pthread_mutex_t mutex;
- }wanning_cache_t;
- static wanning_cache_t wan;
- waning_info_t *next = NULL;
- void wanning_init()
- {
- wan.list = generic_list_create(MAX_WANIING_LENTH);
- pthread_mutex_init(&wan.mutex,NULL);
- }
- void wanning_insert(waning_info_t wanning)
- {
- pthread_mutex_lock(&wan.mutex);
- generic_list_append(wan.list,&wanning,sizeof(waning_info_t));
- pthread_mutex_unlock(&wan.mutex);
- }
- int wanning_get_count()
- {
- int val = 0;
- pthread_mutex_lock(&wan.mutex);
- val = generic_list_get_count(wan.list);
- pthread_mutex_unlock(&wan.mutex);
- return val;
- }
- int wanning_get(waning_info_t *waning,uint8_t lenth)
- {
- if(waning)
- {
- pthread_mutex_lock(&wan.mutex);
- generic_list_get(wan.list,waning,lenth);
- pthread_mutex_unlock(&wan.mutex);
- }
- return 0;
- }
- waning_info_t * waning_get_info(uint8_t index)
- {
- waning_info_t *info = NULL;
- pthread_mutex_lock(&wan.mutex);
- info = (waning_info_t *)generic_list_get_index(wan.list,index);
- pthread_mutex_unlock(&wan.mutex);
- return info;
- }
- void wanning_deinit()
- {
-
- }
|