lightduer_data_cache.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Copyright (2017) Baidu Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * File: lightduer_data_cache.h
  18. * Auth: Su Hao (suhao@baidu.com)
  19. * Desc: Light duer stored the send data.
  20. */
  21. #ifndef BAIDU_DUER_LIGHTDUER_COMMON_LIGHTDUER_DATA_CACHE_H
  22. #define BAIDU_DUER_LIGHTDUER_COMMON_LIGHTDUER_DATA_CACHE_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. typedef struct _duer_transmit_data_s {
  27. void * data;
  28. size_t size;
  29. } duer_dcache_item;
  30. void duer_dcache_initialize(void);
  31. /**
  32. * @param data, the memory address
  33. * @param size, the size of memory
  34. * @param need_copy, indicate whether the memroy @data need another copy
  35. * DUER_FALSE means the invoker transfer the memory ownership,
  36. * DUER_TRUE is default value, which means invoker still own the memory,
  37. * so invoker have the responsibility to release it when no long used.
  38. */
  39. duer_status_t duer_dcache_push(const void *data, size_t size, duer_bool need_copy);
  40. duer_dcache_item *duer_dcache_top(void);
  41. void duer_dcache_pop(void);
  42. void *duer_dcache_create_iterator(void);
  43. void *duer_dcache_get_next(void *iterator);
  44. duer_dcache_item *duer_dcache_get_data(void *iterator);
  45. size_t duer_dcache_length(void);
  46. void duer_dcache_clear(void);
  47. void duer_dcache_finalize(void);
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif/*BAIDU_DUER_LIGHTDUER_COMMON_LIGHTDUER_DATA_CACHE_H*/