ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
queue.h File Reference
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  queue_entry
 

Typedefs

typedef void(* queue_destroy_func_t )(void *data)
 
typedef void(* queue_foreach_func_t )(void *data, void *user_data)
 
typedef bool(* queue_match_func_t )(const void *data, const void *match_data)
 

Functions

struct queuequeue_new (void)
 
void queue_destroy (struct queue *queue, queue_destroy_func_t destroy)
 
bool queue_push_tail (struct queue *queue, void *data)
 
bool queue_push_head (struct queue *queue, void *data)
 
bool queue_push_after (struct queue *queue, void *entry, void *data)
 
void * queue_pop_head (struct queue *queue)
 
void * queue_peek_head (struct queue *queue)
 
void * queue_peek_tail (struct queue *queue)
 
void queue_foreach (struct queue *queue, queue_foreach_func_t function, void *user_data)
 
void * queue_find (struct queue *queue, queue_match_func_t function, const void *match_data)
 
bool queue_remove (struct queue *queue, void *data)
 
void * queue_remove_if (struct queue *queue, queue_match_func_t function, void *user_data)
 
unsigned int queue_remove_all (struct queue *queue, queue_match_func_t function, void *user_data, queue_destroy_func_t destroy)
 
const struct queue_entryqueue_get_entries (struct queue *queue)
 
unsigned int queue_length (struct queue *queue)
 
bool queue_isempty (struct queue *queue)
 

Typedef Documentation

typedef void(* queue_destroy_func_t)(void *data)

Definition at line 26 of file queue.h.

typedef void(* queue_foreach_func_t)(void *data, void *user_data)

Definition at line 46 of file queue.h.

typedef bool(* queue_match_func_t)(const void *data, const void *match_data)

Definition at line 51 of file queue.h.

Function Documentation

void queue_destroy ( struct queue queue,
queue_destroy_func_t  destroy 
)

destroy all queue structure elements

Parameters
queuepointer to the queue structure
destroyfunction making data deallocation

Definition at line 102 of file queue.c.

References queue_remove_all(), and queue_unref().

Referenced by attribute_destroy(), bt_att_free(), bt_gatt_client_free(), discovery_op_free(), gatt_db_destroy(), gatt_db_new(), and notify_chrc_free().

void* queue_find ( struct queue queue,
queue_match_func_t  function,
const void *  match_data 
)
Parameters
queuequeue pointer
functionfunction call to make comparison
match_datadata to match with queue entry
Returns
found entry and return pointer to user data (queued data) or NULL if not found

Definition at line 376 of file queue.c.

References queue_entry::data, direct_match(), queue::head, and queue_entry::next.

Referenced by bt_gatt_client_write_execute(), gatt_db_get_attribute(), gatt_db_get_service_with_uuid(), gatt_db_unregister(), get_reliable_request(), and register_notify().

void queue_foreach ( struct queue queue,
queue_foreach_func_t  function,
void *  user_data 
)

iterator for the queue

Parameters
queuequeue pointer
functionfunction(void *data, void *user_data) to call for each element
user_datauser pointer to pass to function

Definition at line 325 of file queue.c.

References queue_entry::data, queue::head, queue_entry::next, queue_entry_ref(), queue_entry_unref(), queue_ref(), queue_unref(), and queue::ref_count.

Referenced by disconnect_cb(), gatt_db_find_by_type(), gatt_db_find_by_type_value(), gatt_db_find_information(), gatt_db_foreach_service_in_range(), gatt_db_read_by_type(), notify_cb(), and notify_service_changed().

const struct queue_entry* queue_get_entries ( struct queue queue)

return queue head pointer

Parameters
queuequeue pointer
Returns
queue head

Definition at line 540 of file queue.c.

References queue::head.

Referenced by find_insert_loc(), gatt_db_read_by_group_type(), and handle_notify().

bool queue_isempty ( struct queue queue)

test if queue is empty

Parameters
queuequeue pointer
Returns

Definition at line 569 of file queue.c.

References queue::entries.

Referenced by cancel_long_write_cb(), discover_primary_cb(), gatt_db_isempty(), handle_notify(), notify_service_changed(), start_next_long_write(), and wakeup_writer().

unsigned int queue_length ( struct queue queue)

return queue length

Parameters
queuequeue pointer
Returns
return 0 or queue elements count

Definition at line 555 of file queue.c.

References queue::entries.

struct queue* queue_new ( void  )

create a new queue structure

Returns
queue reference

Definition at line 81 of file queue.c.

References queue::entries, queue::head, new0, queue_ref(), and queue::tail.

Referenced by bt_att_new(), bt_gatt_client_new(), discovery_op_create(), gatt_db_new(), new_attribute(), and notify_chrc_create().

void* queue_peek_head ( struct queue queue)

peek data from the head of the queue

Parameters
queuequeue pointer

Definition at line 297 of file queue.c.

References queue_entry::data, and queue::head.

void* queue_peek_tail ( struct queue queue)

peek data from the tail of the queue

Parameters
queuequeue pointer

Definition at line 310 of file queue.c.

References queue_entry::data, and queue::tail.

bool queue_push_after ( struct queue queue,
void *  entry,
void *  data 
)

push a queue entry allocated with data and set it after the entry

Parameters
queuequeue pointer where to allocate data
entryelement queue where to put the data after
datadata to queue
Returns

Definition at line 229 of file queue.c.

References queue_entry::data, queue::entries, queue::head, queue_entry::next, queue_entry_new(), and queue::tail.

Referenced by gatt_db_insert_service().

bool queue_push_head ( struct queue queue,
void *  data 
)

push a queue entry allocated with data and set it at the head of queue

Parameters
queuequeue pointer where to allocate data
datadata to queue
Returns

Definition at line 198 of file queue.c.

References queue::entries, queue::head, queue_entry::next, queue_entry_new(), and queue::tail.

Referenced by gatt_db_insert_service(), and handle_error_rsp().

bool queue_push_tail ( struct queue queue,
void *  data 
)
bool queue_remove ( struct queue queue,
void *  data 
)

remove queue element holding data

Parameters
queuequeue pointer
datadata pointer
Returns
false if not found, true if element removed

Definition at line 402 of file queue.c.

References queue_entry::data, queue::entries, queue::head, queue_entry::next, queue_entry_unref(), and queue::tail.

Referenced by cancel_long_write_req(), enable_ccc_callback(), gatt_db_remove_service(), gatt_db_unregister(), read_timeout(), register_notify(), request_unref(), and write_timeout().

unsigned int queue_remove_all ( struct queue queue,
queue_match_func_t  function,
void *  user_data,
queue_destroy_func_t  destroy 
)

remove all queue element

Parameters
queuequeue pointer
functionfunction used to match data deallocation
user_datadata pointer used in deallocation function
destroyfunction for data deallocation
Returns
count of element destroyed (0 if none)

Definition at line 487 of file queue.c.

References queue_entry::data, queue::entries, queue::head, queue_entry::next, queue_entry_unref(), queue_remove_if(), and queue::tail.

Referenced by bt_att_cancel_all(), bt_att_unregister_all(), bt_gatt_client_cancel_all(), enable_ccc_callback(), gatt_client_remove_all_notify_in_range(), gatt_client_remove_notify_chrcs_in_range(), gatt_db_clear(), gatt_db_clear_range(), and queue_destroy().

void* queue_remove_if ( struct queue queue,
queue_match_func_t  function,
void *  user_data 
)

remove element match by function(void *data, void *match_data) where match_data = user_data

Parameters
queuequeue pointer
functionfunction call to make comparison
user_datadata to match queue element in function
Returns
NULL if not found or queue entry matching criteria

Definition at line 440 of file queue.c.

References queue_entry::data, queue::entries, queue::head, queue_entry::next, queue_entry_unref(), and queue::tail.

Referenced by bt_att_cancel(), bt_att_unregister(), bt_att_unregister_disconnect(), bt_gatt_client_cancel(), bt_gatt_client_unregister_notify(), gatt_db_attribute_read_result(), gatt_db_attribute_write_result(), and queue_remove_all().