Document of c-modernization-kit (porter) 1.0.0

Loading...
Searching...
No Matches
Macros | Functions
potrSendQueue.c File Reference

非同期送信キューの実装。 More...

`#include <stdlib.h>`
`#include <string.h>`
`#include <time.h>`
`#include <porter_const.h>`
`#include "potrSendQueue.h"`
Include dependency graph for potrSendQueue.c:

Go to the source code of this file.

## Macros
#define | POTR_MUTEX_INIT(m)
#define | POTR_MUTEX_LOCK(m)
#define | POTR_MUTEX_UNLOCK(m)
#define | POTR_MUTEX_DESTROY(m)
#define | POTR_COND_INIT(c)
#define | POTR_COND_WAIT(c, m)
#define | POTR_COND_SIGNAL(c)
#define | POTR_COND_BROADCAST(c)
#define | POTR_COND_DESTROY(c)

## Functions
int | potr_send_queue_init (PotrSendQueue *q, size_t depth, uint16_t max_payload)
void | potr_send_queue_destroy (PotrSendQueue *q)
int | potr_send_queue_push (PotrSendQueue *q, PotrPeerId peer_id, uint16_t flags, const void *payload, uint16_t payload_len)
int | potr_send_queue_push_wait (PotrSendQueue *q, PotrPeerId peer_id, uint16_t flags, const void *payload, uint16_t payload_len, volatile int *running)
int | potr_send_queue_pop (PotrSendQueue *q, PotrPayloadElem *out, volatile int *running)
int | potr_send_queue_peek (PotrSendQueue *q, PotrPayloadElem *out)
int | potr_send_queue_peek_timed (PotrSendQueue *q, PotrPayloadElem *out, uint32_t timeout_ms)
int | potr_send_queue_try_pop (PotrSendQueue *q, PotrPayloadElem *out)
void | potr_send_queue_complete (PotrSendQueue *q)
void | potr_send_queue_wait_drained (PotrSendQueue *q)
void | potr_send_queue_shutdown (PotrSendQueue *q)

## Detailed Description

非同期送信キューの実装。

Author
  c-modernization-kit sample team

Date
  2026/03/08

Version
  1.0.0

Copyright
  Copyright (C) CompanyName, Ltd. 2026. All rights reserved.

Definition in file potrSendQueue.c.

## Macro Definition Documentation

## ◆ POTR_MUTEX_INIT

#define POTR_MUTEX_INIT | ( |  | m | ) |

Value:
pthread_mutex_init((m), NULL)

Definition at line 29 of file potrSendQueue.c.

Referenced by potr_send_queue_init().

## ◆ POTR_MUTEX_LOCK

#define POTR_MUTEX_LOCK | ( |  | m | ) |

Value:
pthread_mutex_lock(m)

Definition at line 30 of file potrSendQueue.c.

Referenced by potr_send_queue_complete(), potr_send_queue_peek(), potr_send_queue_peek_timed(), potr_send_queue_pop(), potr_send_queue_push(), potr_send_queue_push_wait(), potr_send_queue_shutdown(), potr_send_queue_try_pop(), and potr_send_queue_wait_drained().

## ◆ POTR_MUTEX_UNLOCK

#define POTR_MUTEX_UNLOCK | ( |  | m | ) |

Value:
pthread_mutex_unlock(m)

Definition at line 31 of file potrSendQueue.c.

Referenced by potr_send_queue_complete(), potr_send_queue_peek(), potr_send_queue_peek_timed(), potr_send_queue_pop(), potr_send_queue_push(), potr_send_queue_push_wait(), potr_send_queue_shutdown(), potr_send_queue_try_pop(), and potr_send_queue_wait_drained().

## ◆ POTR_MUTEX_DESTROY

#define POTR_MUTEX_DESTROY | ( |  | m | ) |

Value:
pthread_mutex_destroy(m)

Definition at line 32 of file potrSendQueue.c.

Referenced by potr_send_queue_destroy().

## ◆ POTR_COND_INIT

#define POTR_COND_INIT | ( |  | c | ) |

Value:
pthread_cond_init((c), NULL)

Definition at line 33 of file potrSendQueue.c.

Referenced by potr_send_queue_init().

## ◆ POTR_COND_WAIT

#define POTR_COND_WAIT | ( |  | c,
|  |  | m )

Value:
pthread_cond_wait((c), (m))

Definition at line 34 of file potrSendQueue.c.

Referenced by potr_send_queue_pop(), potr_send_queue_push_wait(), and potr_send_queue_wait_drained().

## ◆ POTR_COND_SIGNAL

#define POTR_COND_SIGNAL | ( |  | c | ) |

Value:
pthread_cond_signal(c)

Definition at line 35 of file potrSendQueue.c.

Referenced by potr_send_queue_complete(), potr_send_queue_push(), and potr_send_queue_push_wait().

## ◆ POTR_COND_BROADCAST

#define POTR_COND_BROADCAST | ( |  | c | ) |

Value:
pthread_cond_broadcast(c)

Definition at line 36 of file potrSendQueue.c.

Referenced by potr_send_queue_complete(), and potr_send_queue_shutdown().

## ◆ POTR_COND_DESTROY

#define POTR_COND_DESTROY | ( |  | c | ) |

Value:
pthread_cond_destroy(c)

Definition at line 37 of file potrSendQueue.c.

Referenced by potr_send_queue_destroy().

## Function Documentation

## ◆ potr_send_queue_init()

int potr_send_queue_init | ( | PotrSendQueue * | q,
|  | size_t | depth,
|  | uint16_t | max_payload )

Definition at line 51 of file potrSendQueue.c.

References PotrSendQueue::depth, PotrSendQueue::drained, PotrSendQueue::entries, PotrPayloadElem::flags, PotrSendQueue::mutex, PotrSendQueue::not_empty, PotrSendQueue::not_full, PotrPayloadElem::payload, PotrPayloadElem::payload_len, PotrSendQueue::payload_pool, PotrPayloadElem::peer_id, POTR_COND_INIT, POTR_ERROR, POTR_MUTEX_INIT, POTR_PEER_NA, and POTR_SUCCESS.

Referenced by potrOpenService(), and reset_send_queue().

Here is the caller graph for this function:

## ◆ potr_send_queue_destroy()

void potr_send_queue_destroy | ( | PotrSendQueue * | q | ) |

Definition at line 87 of file potrSendQueue.c.

References PotrSendQueue::drained, PotrSendQueue::entries, PotrSendQueue::mutex, PotrSendQueue::not_empty, PotrSendQueue::not_full, PotrSendQueue::payload_pool, POTR_COND_DESTROY, and POTR_MUTEX_DESTROY.

Referenced by potrCloseService(), potrOpenService(), and reset_send_queue().

Here is the caller graph for this function:

## ◆ potr_send_queue_push()

int potr_send_queue_push | ( | PotrSendQueue * | q,
|  | PotrPeerId | peer_id,
|  | uint16_t | flags,
|  | const void * | payload,
|  | uint16_t | payload_len )

Definition at line 100 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::depth, PotrSendQueue::entries, PotrPayloadElem::flags, PotrSendQueue::inflight, PotrSendQueue::mutex, PotrSendQueue::not_empty, PotrPayloadElem::payload, PotrPayloadElem::payload_len, PotrPayloadElem::peer_id, POTR_COND_SIGNAL, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, POTR_SUCCESS, and PotrSendQueue::tail.

## ◆ potr_send_queue_push_wait()

int potr_send_queue_push_wait | ( | PotrSendQueue * | q,
|  | PotrPeerId | peer_id,
|  | uint16_t | flags,
|  | const void * | payload,
|  | uint16_t | payload_len,
|  | volatile int * | running )

Definition at line 126 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::depth, PotrSendQueue::entries, PotrPayloadElem::flags, PotrSendQueue::inflight, PotrSendQueue::mutex, PotrSendQueue::not_empty, PotrSendQueue::not_full, PotrPayloadElem::payload, PotrPayloadElem::payload_len, PotrPayloadElem::peer_id, POTR_COND_SIGNAL, POTR_COND_WAIT, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, POTR_SUCCESS, running, and PotrSendQueue::tail.

Referenced by send_to_peer().

Here is the caller graph for this function:

## ◆ potr_send_queue_pop()

int potr_send_queue_pop | ( | PotrSendQueue * | q,
|  | PotrPayloadElem * | out,
|  | volatile int * | running )

Definition at line 159 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::depth, PotrSendQueue::entries, PotrSendQueue::head, PotrSendQueue::inflight, PotrSendQueue::mutex, PotrSendQueue::not_empty, POTR_COND_WAIT, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, POTR_SUCCESS, and running.

Referenced by send_thread_func().

Here is the caller graph for this function:

## ◆ potr_send_queue_peek()

int potr_send_queue_peek | ( | PotrSendQueue * | q,
|  | PotrPayloadElem * | out )

Definition at line 185 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::entries, PotrSendQueue::head, PotrSendQueue::mutex, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, and POTR_SUCCESS.

Referenced by send_packed_peer_mode(), and send_thread_func().

Here is the caller graph for this function:

## ◆ potr_send_queue_peek_timed()

int potr_send_queue_peek_timed | ( | PotrSendQueue * | q,
|  | PotrPayloadElem * | out,
|  | uint32_t | timeout_ms )

Definition at line 202 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::entries, PotrSendQueue::head, PotrSendQueue::mutex, PotrSendQueue::not_empty, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, and POTR_SUCCESS.

Referenced by send_thread_func().

Here is the caller graph for this function:

## ◆ potr_send_queue_try_pop()

int potr_send_queue_try_pop | ( | PotrSendQueue * | q,
|  | PotrPayloadElem * | out )

Definition at line 238 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::depth, PotrSendQueue::entries, PotrSendQueue::head, PotrSendQueue::inflight, PotrSendQueue::mutex, POTR_ERROR, POTR_MUTEX_LOCK, POTR_MUTEX_UNLOCK, and POTR_SUCCESS.

Referenced by send_packed_peer_mode(), and send_thread_func().

Here is the caller graph for this function:

## ◆ potr_send_queue_complete()

void potr_send_queue_complete | ( | PotrSendQueue * | q | ) |

Definition at line 258 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::drained, PotrSendQueue::inflight, PotrSendQueue::mutex, PotrSendQueue::not_full, POTR_COND_BROADCAST, POTR_COND_SIGNAL, POTR_MUTEX_LOCK, and POTR_MUTEX_UNLOCK.

Referenced by send_packed_peer_mode(), and send_thread_func().

Here is the caller graph for this function:

## ◆ potr_send_queue_wait_drained()

void potr_send_queue_wait_drained | ( | PotrSendQueue * | q | ) |

Definition at line 280 of file potrSendQueue.c.

References PotrSendQueue::count, PotrSendQueue::drained, PotrSendQueue::inflight, PotrSendQueue::mutex, POTR_COND_WAIT, POTR_MUTEX_LOCK, and POTR_MUTEX_UNLOCK.

Referenced by potrCloseService(), and send_to_peer().

Here is the caller graph for this function:

## ◆ potr_send_queue_shutdown()

void potr_send_queue_shutdown | ( | PotrSendQueue * | q | ) |

Definition at line 293 of file potrSendQueue.c.

References PotrSendQueue::mutex, PotrSendQueue::not_empty, PotrSendQueue::not_full, POTR_COND_BROADCAST, POTR_MUTEX_LOCK, and POTR_MUTEX_UNLOCK.

Referenced by potr_send_thread_stop().

Here is the caller graph for this function: