mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-12-11 01:06:49 +08:00
SNMP: Add some comments in thread sync code
This commit is contained in:
parent
8cd33a5e41
commit
208f24a20c
@ -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);
|
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)
|
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn)
|
||||||
{
|
{
|
||||||
sys_mutex_new(&instance->sem_usage_mutex);
|
sys_mutex_new(&instance->sem_usage_mutex);
|
||||||
|
|||||||
@ -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);
|
typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg);
|
||||||
|
|
||||||
|
|
||||||
|
/** Thread sync runtime data. For internal usage only. */
|
||||||
struct threadsync_data
|
struct threadsync_data
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
@ -66,6 +67,7 @@ struct threadsync_data
|
|||||||
struct snmp_node_instance proxy_instance;
|
struct snmp_node_instance proxy_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */
|
||||||
struct snmp_threadsync_instance
|
struct snmp_threadsync_instance
|
||||||
{
|
{
|
||||||
sys_sem_t sem;
|
sys_sem_t sem;
|
||||||
@ -74,11 +76,12 @@ struct snmp_threadsync_instance
|
|||||||
struct threadsync_data data;
|
struct threadsync_data data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* thread sync node */
|
/** SNMP thread sync proxy leaf node */
|
||||||
struct snmp_threadsync_node
|
struct snmp_threadsync_node
|
||||||
{
|
{
|
||||||
/* inherited "base class" members */
|
/* inherited "base class" members */
|
||||||
struct snmp_leaf_node node;
|
struct snmp_leaf_node node;
|
||||||
|
|
||||||
const struct snmp_leaf_node *target;
|
const struct snmp_leaf_node *target;
|
||||||
struct snmp_threadsync_instance *instance;
|
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_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);
|
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_NODE_THREADSYNC, (oid) }, \
|
||||||
snmp_threadsync_get_instance, \
|
snmp_threadsync_get_instance, \
|
||||||
snmp_threadsync_get_next_instance }, \
|
snmp_threadsync_get_next_instance }, \
|
||||||
(target), \
|
(target_leaf_node), \
|
||||||
(locks) }
|
(threadsync_instance) }
|
||||||
|
|
||||||
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user