diff options
| author | 2026-09-14 08:50:45 -0400 | |
|---|---|---|
| committer | 2026-09-14 08:50:45 -0400 | |
| commit | a2dad19f83ac00101489d7e00751ff9e17719344 (patch) | |
| tree | bdaf339e76983ffe85d508e4ff3f3e4065624971 /src/packet_cache.c | |
| parent | 36f09a0c35657f5c7379624c8a2463aafb953bd4 (diff) | |
| download | libnaunet-a2dad19f83ac00101489d7e00751ff9e17719344.tar.gz libnaunet-a2dad19f83ac00101489d7e00751ff9e17719344.tar.bz2 libnaunet-a2dad19f83ac00101489d7e00751ff9e17719344.zip | |
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/packet_cache.c')
| -rw-r--r-- | src/packet_cache.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/packet_cache.c b/src/packet_cache.c index 2e907b3..8398d6c 100644 --- a/src/packet_cache.c +++ b/src/packet_cache.c @@ -10,12 +10,6 @@ void nn_packet_cache_init(struct nn_packet_cache *cache, u32 size) nn_mutex_init(&cache->mutex); } -bool nn_packet_cache_available(struct nn_packet_cache *cache) -{ - nn_mutex_lock(&cache->mutex); - return !cache->disabled; -} - void nn_packet_cache_send_packet(struct nn_packet_cache *cache, struct nn_packet *packet) { al_assert(!cache->disabled); @@ -57,16 +51,6 @@ struct nn_packet *nn_packet_cache_at(struct nn_packet_cache *cache, u32 index) return al_array_at(cache->cache, index); } -void nn_packet_cache_lock(struct nn_packet_cache *cache) -{ - nn_mutex_lock(&cache->mutex); -} - -void nn_packet_cache_unlock(struct nn_packet_cache *cache) -{ - nn_mutex_unlock(&cache->mutex); -} - void nn_packet_cache_disable(struct nn_packet_cache *cache) { nn_mutex_lock(&cache->mutex); @@ -77,6 +61,12 @@ void nn_packet_cache_disable(struct nn_packet_cache *cache) nn_mutex_unlock(&cache->mutex); } +bool nn_packet_cache_disabled(struct nn_packet_cache *cache) +{ + nn_mutex_lock(&cache->mutex); + return cache->disabled; +} + void nn_packet_cache_enable(struct nn_packet_cache *cache) { nn_mutex_lock(&cache->mutex); @@ -84,8 +74,14 @@ void nn_packet_cache_enable(struct nn_packet_cache *cache) nn_mutex_unlock(&cache->mutex); } +void nn_packet_cache_unlock(struct nn_packet_cache *cache) +{ + nn_mutex_unlock(&cache->mutex); +} + void nn_packet_cache_free(struct nn_packet_cache *cache) { + al_assert(!cache->cache.count); al_array_free(cache->cache); nn_mutex_destroy(&cache->mutex); nn_cond_destroy(&cache->cond); |