Document of c-modernization-kit (porter) 1.0.0
Loading...
Searching...
No Matches
potrSendQueue.h File Reference

非同期送信キューの型定義と操作関数。 More...

#include <stddef.h>
#include <porter_const.h>
#include <porter_type.h>
#include <pthread.h>
Include dependency graph for potrSendQueue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PotrPayloadElem
 送信キューの 1 エントリ。ペイロードエレメント 1 個分のデータを保持する。 More...
struct  PotrSendQueue
 非同期送信キュー。 More...

Typedefs

typedef pthread_mutex_t PotrMutex
typedef pthread_cond_t PotrCondVar

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

ノンブロッキング送信 (potrSend の flags に POTR_SEND_BLOCKING なし) で使用される スレッドセーフな送信キューです。
ペイロードエレメントをリングバッファに積み、送信スレッドが順に sendto で送出します。
ブロッキング送信は potr_send_queue_wait_drained() で先行キューの sendto 完了を待ってから直接送信します。

Definition in file potrSendQueue.h.

Typedef Documentation

◆ PotrMutex

typedef pthread_mutex_t PotrMutex

Definition at line 32 of file potrSendQueue.h.

◆ PotrCondVar

typedef pthread_cond_t PotrCondVar

Definition at line 33 of file potrSendQueue.h.

Function Documentation

◆ potr_send_queue_init()

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

◆ potr_send_queue_destroy()

void potr_send_queue_destroy ( PotrSendQueue * q)
extern

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()

◆ 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 )
extern

◆ potr_send_queue_pop()

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

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 )
extern

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 )
extern

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 )
extern

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)
extern

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)
extern

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)
extern

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: