From 208f24a20c374a32a6bba621601234106286b69a Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 4 Feb 2016 16:20:46 +0100 Subject: [PATCH] SNMP: Add some comments in thread sync code --- src/apps/snmp/snmp_threadsync.c | 1 + src/include/lwip/apps/snmp_threadsync.h | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/apps/snmp/snmp_threadsync.c b/src/apps/snmp/snmp_threadsync.c index ab312a4e..cc5c0322 100644 --- a/src/apps/snmp/snmp_threadsync.c +++ b/src/apps/snmp/snmp_threadsync.c @@ -196,6 +196,7 @@ snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, stru return do_sync(root_oid, root_oid_len, instance, get_next_instance_synced); } +/** Initializes thread synchronization instance */ void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn) { sys_mutex_new(&instance->sem_usage_mutex); diff --git a/src/include/lwip/apps/snmp_threadsync.h b/src/include/lwip/apps/snmp_threadsync.h index f2c8fe55..d45417aa 100644 --- a/src/include/lwip/apps/snmp_threadsync.h +++ b/src/include/lwip/apps/snmp_threadsync.h @@ -48,6 +48,7 @@ typedef void (*snmp_threadsync_called_fn)(void* arg); typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg); +/** Thread sync runtime data. For internal usage only. */ struct threadsync_data { union { @@ -66,6 +67,7 @@ struct threadsync_data struct snmp_node_instance proxy_instance; }; +/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */ struct snmp_threadsync_instance { sys_sem_t sem; @@ -74,11 +76,12 @@ struct snmp_threadsync_instance struct threadsync_data data; }; -/* thread sync node */ +/** SNMP thread sync proxy leaf node */ struct snmp_threadsync_node { /* inherited "base class" members */ struct snmp_leaf_node node; + const struct snmp_leaf_node *target; struct snmp_threadsync_instance *instance; }; @@ -86,12 +89,12 @@ struct snmp_threadsync_node snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target, locks) \ +#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \ {{{ SNMP_NODE_THREADSYNC, (oid) }, \ snmp_threadsync_get_instance, \ snmp_threadsync_get_next_instance }, \ - (target), \ - (locks) } + (target_leaf_node), \ + (threadsync_instance) } void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);