diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-19 18:12:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-19 18:12:49 +0000 |
commit | 506899aa2be2b4d5dc09c1740969c28ddf43c82d (patch) | |
tree | 12815e3faeca1c535a67a601ecab014c871068b6 /src/util | |
parent | 1532728eb9a0fd858528a574ce27155436eaf76a (diff) | |
download | gnunet-506899aa2be2b4d5dc09c1740969c28ddf43c82d.tar.gz gnunet-506899aa2be2b4d5dc09c1740969c28ddf43c82d.zip |
converting nse to new service API
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/mq.c | 88 |
1 files changed, 53 insertions, 35 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index 01cdf764b..e69d1c483 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -952,19 +952,68 @@ GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, | |||
952 | } | 952 | } |
953 | 953 | ||
954 | 954 | ||
955 | /** | ||
956 | * Call a callback once the envelope has been sent, that is, | ||
957 | * sending it can not be canceled anymore. | ||
958 | * There can be only one notify sent callback per envelope. | ||
959 | * | ||
960 | * @param ev message to call the notify callback for | ||
961 | * @param cb the notify callback | ||
962 | * @param cb_cls closure for the callback | ||
963 | */ | ||
955 | void | 964 | void |
956 | GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *mqm, | 965 | GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *mqm, |
957 | GNUNET_MQ_NotifyCallback cb, | 966 | GNUNET_MQ_NotifyCallback cb, |
958 | void *cls) | 967 | void *cb_cls) |
959 | { | 968 | { |
960 | mqm->sent_cb = cb; | 969 | mqm->sent_cb = cb; |
961 | mqm->sent_cls = cls; | 970 | mqm->sent_cls = cb_cls; |
962 | } | 971 | } |
963 | 972 | ||
964 | 973 | ||
974 | /** | ||
975 | * Handle we return for callbacks registered to be | ||
976 | * notified when #GNUNET_MQ_destroy() is called on a queue. | ||
977 | */ | ||
978 | struct GNUNET_MQ_DestroyNotificationHandle | ||
979 | { | ||
980 | /** | ||
981 | * Kept in a DLL. | ||
982 | */ | ||
983 | struct GNUNET_MQ_DestroyNotificationHandle *prev; | ||
984 | |||
985 | /** | ||
986 | * Kept in a DLL. | ||
987 | */ | ||
988 | struct GNUNET_MQ_DestroyNotificationHandle *next; | ||
989 | |||
990 | /** | ||
991 | * Queue to notify about. | ||
992 | */ | ||
993 | struct GNUNET_MQ_Handle *mq; | ||
994 | |||
995 | /** | ||
996 | * Function to call. | ||
997 | */ | ||
998 | GNUNET_SCHEDULER_TaskCallback cb; | ||
999 | |||
1000 | /** | ||
1001 | * Closure for @e cb. | ||
1002 | */ | ||
1003 | void *cb_cls; | ||
1004 | }; | ||
1005 | |||
1006 | |||
1007 | /** | ||
1008 | * Destroy the message queue. | ||
1009 | * | ||
1010 | * @param mq message queue to destroy | ||
1011 | */ | ||
965 | void | 1012 | void |
966 | GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | 1013 | GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) |
967 | { | 1014 | { |
1015 | struct GNUNET_MQ_DestroyNotificationHandle *dnh; | ||
1016 | |||
968 | if (NULL != mq->destroy_impl) | 1017 | if (NULL != mq->destroy_impl) |
969 | { | 1018 | { |
970 | mq->destroy_impl (mq, mq->impl_state); | 1019 | mq->destroy_impl (mq, mq->impl_state); |
@@ -996,6 +1045,8 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
996 | mq->queue_length--; | 1045 | mq->queue_length--; |
997 | } | 1046 | } |
998 | GNUNET_assert (0 == mq->queue_length); | 1047 | GNUNET_assert (0 == mq->queue_length); |
1048 | while (NULL != (dnh = mq->dnh_head)) | ||
1049 | dnh->cb (dnh->cb_cls); | ||
999 | if (NULL != mq->assoc_map) | 1050 | if (NULL != mq->assoc_map) |
1000 | { | 1051 | { |
1001 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); | 1052 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); |
@@ -1184,39 +1235,6 @@ GNUNET_MQ_set_options (struct GNUNET_MQ_Handle *mq, | |||
1184 | 1235 | ||
1185 | 1236 | ||
1186 | /** | 1237 | /** |
1187 | * Handle we return for callbacks registered to be | ||
1188 | * notified when #GNUNET_MQ_destroy() is called on a queue. | ||
1189 | */ | ||
1190 | struct GNUNET_MQ_DestroyNotificationHandle | ||
1191 | { | ||
1192 | /** | ||
1193 | * Kept in a DLL. | ||
1194 | */ | ||
1195 | struct GNUNET_MQ_DestroyNotificationHandle *prev; | ||
1196 | |||
1197 | /** | ||
1198 | * Kept in a DLL. | ||
1199 | */ | ||
1200 | struct GNUNET_MQ_DestroyNotificationHandle *next; | ||
1201 | |||
1202 | /** | ||
1203 | * Queue to notify about. | ||
1204 | */ | ||
1205 | struct GNUNET_MQ_Handle *mq; | ||
1206 | |||
1207 | /** | ||
1208 | * Function to call. | ||
1209 | */ | ||
1210 | GNUNET_SCHEDULER_TaskCallback cb; | ||
1211 | |||
1212 | /** | ||
1213 | * Closure for @e cb. | ||
1214 | */ | ||
1215 | void *cb_cls; | ||
1216 | }; | ||
1217 | |||
1218 | |||
1219 | /** | ||
1220 | * Register function to be called whenever @a mq is being | 1238 | * Register function to be called whenever @a mq is being |
1221 | * destroyed. | 1239 | * destroyed. |
1222 | * | 1240 | * |