agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
msg_queue.h File Reference
#include <zrtos/types.h>
#include <zrtos/cbuffer.h>
Include dependency graph for msg_queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _zrtos_msg_queue_header_t
 
struct  _zrtos_msg_queue_t
 
struct  _zrtos_msg_queue_write_transaction_t
 

Typedefs

typedef struct _zrtos_msg_queue_header_t zrtos_msg_queue_header_t
 
typedef struct _zrtos_msg_queue_t zrtos_msg_queue_t
 
typedef struct _zrtos_msg_queue_write_transaction_t zrtos_msg_queue_write_transaction_t
 

Functions

void zrtos_msg_queue__start_write_transaction (zrtos_msg_queue_t *thiz, zrtos_msg_queue_write_transaction_t *txn)
 
void zrtos_msg_queue__rollback_write_transaction (zrtos_msg_queue_t *thiz, zrtos_msg_queue_write_transaction_t *txn)
 
bool zrtos_msg_queue__is_empty (zrtos_msg_queue_t *thiz)
 
zrtos_error_t zrtos_msg_queue__put_length (zrtos_msg_queue_t *thiz, size_t len)
 
zrtos_error_t zrtos_msg_queue__put_data (zrtos_msg_queue_t *thiz, void *data, size_t len)
 
zrtos_error_t zrtos_msg_queue__put_end (zrtos_msg_queue_t *thiz)
 
zrtos_error_t zrtos_msg_queue__put_cbuffer_data (zrtos_msg_queue_t *thiz, zrtos_cbuffer_t *data, size_t length)
 
zrtos_error_t zrtos_msg_queue__put (zrtos_msg_queue_t *thiz, void *data, size_t len)
 
zrtos_error_t zrtos_msg_queue__get (zrtos_msg_queue_t *thiz, void *data, size_t len, size_t *outlen)
 
zrtos_error_t zrtos_msg_queue__pipe_next_message_to_cbuffer (zrtos_msg_queue_t *thiz, zrtos_cbuffer_t *dest, size_t len, size_t *outlen)
 

Typedef Documentation

◆ zrtos_msg_queue_header_t

◆ zrtos_msg_queue_t

◆ zrtos_msg_queue_write_transaction_t

Function Documentation

◆ zrtos_msg_queue__get()

zrtos_error_t zrtos_msg_queue__get ( zrtos_msg_queue_t thiz,
void *  data,
size_t  len,
size_t outlen 
)

Definition at line 140 of file msg_queue.h.

145  {
146  zrtos_error_t ret;
147  if(thiz->header.length){
148 L_READ_MESSAGE_BODY:
149  ret = zrtos_cbuffer__get_ex(
150  &thiz->cbuffer
151  ,data
152  ,ZRTOS_TYPES__MIN(len,thiz->header.length)
153  ,outlen
154  );
155  thiz->header.length -= *outlen;
156  if(thiz->header.length == 0){
157  thiz->msg_count--;
158  }else{
159  ret = ZRTOS_ERROR__AGAIN;
160  }
161  }else if(thiz->msg_count && zrtos_cbuffer__can_read_length(
162  &thiz->cbuffer
163  ,sizeof(thiz->header)
164  )){
165  ret = zrtos_cbuffer__get_ex(
166  &thiz->cbuffer
167  ,&thiz->header
168  ,sizeof(thiz->header)
169  ,outlen
170  );
171  if(zrtos_error__is_success(ret)){
172  goto L_READ_MESSAGE_BODY;
173  }
174  }else{
175  ret = ZRTOS_ERROR__NODATA;
176  }
177  return ret;
178 }
No data available.
Definition: error.h:85
Try again.
Definition: error.h:35
zrtos_error_t zrtos_cbuffer__get_ex(zrtos_cbuffer_t *thiz, void *data, size_t len, size_t *outlen)
Definition: cbuffer.h:336
zrtos_msg_queue_header_t header
Definition: msg_queue.h:25
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
#define ZRTOS_TYPES__MIN(a, b)
Definition: types.h:78
bool zrtos_cbuffer__can_read_length(zrtos_cbuffer_t *thiz, size_t length)
Definition: cbuffer.h:382
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t
Definition: error.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__is_empty()

bool zrtos_msg_queue__is_empty ( zrtos_msg_queue_t thiz)

Definition at line 55 of file msg_queue.h.

55  {
56  return thiz->msg_count == 0 && thiz->header.length == 0;
57 }
zrtos_msg_queue_header_t header
Definition: msg_queue.h:25
Here is the caller graph for this function:

◆ zrtos_msg_queue__pipe_next_message_to_cbuffer()

zrtos_error_t zrtos_msg_queue__pipe_next_message_to_cbuffer ( zrtos_msg_queue_t thiz,
zrtos_cbuffer_t dest,
size_t  len,
size_t outlen 
)

Definition at line 180 of file msg_queue.h.

185  {
186  zrtos_error_t ret;
187  if(thiz->header.length){
188 L_READ_MESSAGE_BODY:
189  ret = zrtos_cbuffer__pipe(
190  &thiz->cbuffer
191  ,dest
192  ,ZRTOS_TYPES__MIN(len,thiz->header.length)
193  ,outlen
194  );
195  thiz->header.length -= *outlen;
196  if(thiz->header.length == 0){
197  thiz->msg_count--;
198  }else{
199  ret = ZRTOS_ERROR__AGAIN;
200  }
201  }else if(thiz->msg_count && zrtos_cbuffer__can_read_length(
202  &thiz->cbuffer
203  ,sizeof(thiz->header)
204  )){
205  ret = zrtos_cbuffer__get_ex(
206  &thiz->cbuffer
207  ,&thiz->header
208  ,sizeof(thiz->header)
209  ,outlen
210  );
211  if(zrtos_error__is_success(ret)){
212  goto L_READ_MESSAGE_BODY;
213  }
214  }else{
215  ret = ZRTOS_ERROR__NODATA;
216  }
217  return ret;
218 }
No data available.
Definition: error.h:85
Try again.
Definition: error.h:35
zrtos_error_t zrtos_cbuffer__get_ex(zrtos_cbuffer_t *thiz, void *data, size_t len, size_t *outlen)
Definition: cbuffer.h:336
zrtos_msg_queue_header_t header
Definition: msg_queue.h:25
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
#define ZRTOS_TYPES__MIN(a, b)
Definition: types.h:78
bool zrtos_cbuffer__can_read_length(zrtos_cbuffer_t *thiz, size_t length)
Definition: cbuffer.h:382
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t
Definition: error.h:20
zrtos_error_t zrtos_cbuffer__pipe(zrtos_cbuffer_t *thiz, zrtos_cbuffer_t *src, size_t length, size_t *outlen)
Definition: cbuffer.h:421
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__put()

zrtos_error_t zrtos_msg_queue__put ( zrtos_msg_queue_t thiz,
void *  data,
size_t  len 
)

Definition at line 116 of file msg_queue.h.

120  {
121  zrtos_msg_queue_header_t header = {
122  .length = len
123  };
124  size_t outlen;
126  &thiz->cbuffer
127  ,2
128  ,&outlen
129  ,&header
130  ,sizeof(header)
131  ,data
132  ,len
133  );
134  if(zrtos_error__is_success(ret)){
135  thiz->msg_count++;
136  }
137  return ret;
138 }
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t zrtos_cbuffer__put_ex(zrtos_cbuffer_t *thiz, size_t len, size_t *outlen,...)
Definition: cbuffer.h:278
zrtos_error_t
Definition: error.h:20
Here is the call graph for this function:

◆ zrtos_msg_queue__put_cbuffer_data()

zrtos_error_t zrtos_msg_queue__put_cbuffer_data ( zrtos_msg_queue_t thiz,
zrtos_cbuffer_t data,
size_t  length 
)

Definition at line 100 of file msg_queue.h.

104  {
106  &thiz->cbuffer
107  ,data
108  ,length
109  );
110  if(zrtos_error__is_success(ret)){
111  thiz->msg_count++;
112  }
113  return ret;
114 }
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t
Definition: error.h:20
zrtos_error_t zrtos_cbuffer__pipe(zrtos_cbuffer_t *thiz, zrtos_cbuffer_t *src, size_t length, size_t *outlen)
Definition: cbuffer.h:421
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__put_data()

zrtos_error_t zrtos_msg_queue__put_data ( zrtos_msg_queue_t thiz,
void *  data,
size_t  len 
)

Definition at line 77 of file msg_queue.h.

81  {
82  size_t outlen;
84  &thiz->cbuffer
85  ,1
86  ,&outlen
87  ,data
88  ,len
89  );
90  return ret;
91 }
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t zrtos_cbuffer__put_ex(zrtos_cbuffer_t *thiz, size_t len, size_t *outlen,...)
Definition: cbuffer.h:278
zrtos_error_t
Definition: error.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__put_end()

zrtos_error_t zrtos_msg_queue__put_end ( zrtos_msg_queue_t thiz)

Definition at line 93 of file msg_queue.h.

95  {
96  thiz->msg_count++;
97  return ZRTOS_ERROR__SUCCESS;
98 }
Successful program execution status.
Definition: error.h:22
Here is the caller graph for this function:

◆ zrtos_msg_queue__put_length()

zrtos_error_t zrtos_msg_queue__put_length ( zrtos_msg_queue_t thiz,
size_t  len 
)

Definition at line 59 of file msg_queue.h.

62  {
63  zrtos_msg_queue_header_t header = {
64  .length = len
65  };
66  size_t outlen;
68  &thiz->cbuffer
69  ,1
70  ,&outlen
71  ,&header
72  ,sizeof(header)
73  );
74  return zrtos_error__is_success(ret);
75 }
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
zrtos_error_t zrtos_cbuffer__put_ex(zrtos_cbuffer_t *thiz, size_t len, size_t *outlen,...)
Definition: cbuffer.h:278
zrtos_error_t
Definition: error.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__rollback_write_transaction()

void zrtos_msg_queue__rollback_write_transaction ( zrtos_msg_queue_t thiz,
zrtos_msg_queue_write_transaction_t txn 
)

Definition at line 44 of file msg_queue.h.

47  {
49  &thiz->cbuffer
50  ,&txn->txn
51  );
52  thiz->msg_count = txn->msg_count;
53 }
void zrtos_cbuffer__rollback_write_transaction(zrtos_cbuffer_t *thiz, zrtos_cbuffer_write_transaction_t *txn)
Definition: cbuffer.h:154
zrtos_cbuffer_write_transaction_t txn
Definition: msg_queue.h:29
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zrtos_msg_queue__start_write_transaction()

void zrtos_msg_queue__start_write_transaction ( zrtos_msg_queue_t thiz,
zrtos_msg_queue_write_transaction_t txn 
)

Definition at line 33 of file msg_queue.h.

36  {
38  &thiz->cbuffer
39  ,&txn->txn
40  );
41  txn->msg_count = thiz->msg_count;
42 }
zrtos_cbuffer_write_transaction_t txn
Definition: msg_queue.h:29
void zrtos_cbuffer__start_write_transaction(zrtos_cbuffer_t *thiz, zrtos_cbuffer_write_transaction_t *txn)
Definition: cbuffer.h:146
zrtos_cbuffer_t cbuffer
Definition: msg_queue.h:23
Here is the call graph for this function:
Here is the caller graph for this function: