You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/11/25 21:01:39 UTC

[43/48] qpid-proton git commit: PROTON-1344: removed unused pn_listener_free, update proactor doc.

PROTON-1344: removed unused pn_listener_free, update proactor doc.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6af49b81
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6af49b81
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6af49b81

Branch: refs/heads/go1
Commit: 6af49b819edb0d7d3aaa9968fc5ee1651f77f492
Parents: 468b719
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Nov 23 11:07:44 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Nov 23 11:08:08 2016 -0500

----------------------------------------------------------------------
 examples/c/proactor/libuv_proactor.c | 18 +++++++++---------
 proton-c/include/proton/listener.h   | 11 ++++++-----
 proton-c/include/proton/proactor.h   | 31 ++++++++++++++++++++-----------
 3 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6af49b81/examples/c/proactor/libuv_proactor.c
----------------------------------------------------------------------
diff --git a/examples/c/proactor/libuv_proactor.c b/examples/c/proactor/libuv_proactor.c
index 9770166..42bbfab 100644
--- a/examples/c/proactor/libuv_proactor.c
+++ b/examples/c/proactor/libuv_proactor.c
@@ -810,6 +810,15 @@ static pn_event_t *proactor_batch_next(pn_event_batch_t *batch) {
   return pn_collector_next(batch_proactor(batch)->collector);
 }
 
+static void pn_listener_free(pn_listener_t *l) {
+  if (l) {
+    if (!l->collector) pn_collector_free(l->collector);
+    if (!l->condition) pn_condition_free(l->condition);
+    if (!l->attachments) pn_free(l->attachments);
+    free(l);
+  }
+}
+
 pn_listener_t *pn_listener() {
   pn_listener_t *l = (pn_listener_t*)calloc(1, sizeof(pn_listener_t));
   if (l) {
@@ -825,15 +834,6 @@ pn_listener_t *pn_listener() {
   return l;
 }
 
-void pn_listener_free(pn_listener_t *l) {
-  if (l) {
-    if (!l->collector) pn_collector_free(l->collector);
-    if (!l->condition) pn_condition_free(l->condition);
-    if (!l->attachments) pn_free(l->attachments);
-    free(l);
-  }
-}
-
 void pn_listener_close(pn_listener_t* l) {
   wakeup(&l->psocket, leader_close);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6af49b81/proton-c/include/proton/listener.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/listener.h b/proton-c/include/proton/listener.h
index cd3d95f..dda1638 100644
--- a/proton-c/include/proton/listener.h
+++ b/proton-c/include/proton/listener.h
@@ -48,15 +48,16 @@ typedef struct pn_listener_t pn_listener_t;
 
 /**
  * Create a listener.
+ *
+ * You can use pn_listener_set_context() or pn_listener_attachments() to set
+ * application data that can be accessed when accepting connections.
+ *
+ * You must pass the returned listener to pn_proactor_listen(), the proactor
+ * will free the listener when it is no longer active.
  */
 PN_EXTERN pn_listener_t *pn_listener(void);
 
 /**
- * Free a listener
- */
-PN_EXTERN void pn_listener_free(pn_listener_t*);
-
-/**
  * Asynchronously accept a connection using the listener.
  *
  * @param[in] connection the listener takes ownership, do not free.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6af49b81/proton-c/include/proton/proactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/proactor.h b/proton-c/include/proton/proactor.h
index cd44526..fdb723b 100644
--- a/proton-c/include/proton/proactor.h
+++ b/proton-c/include/proton/proactor.h
@@ -62,7 +62,8 @@ typedef struct pn_proactor_t pn_proactor_t;
 pn_proactor_t *pn_proactor(void);
 
 /**
- * Free the proactor.
+ * Free the proactor. Abort any open network connections and clean up all
+ * associated resources.
  */
 void pn_proactor_free(pn_proactor_t*);
 
@@ -97,7 +98,7 @@ int pn_proactor_listen(pn_proactor_t *, pn_listener_t *listener, const char *hos
  * Wait for events to handle.
  *
  * Handle events in the returned batch by calling pn_event_batch_next() until it
- * returns NULL. You must call pn_proactor_done() to when you are finished.
+ * returns NULL. You must call pn_proactor_done() when you are finished with the batch.
  *
  * If you call pn_proactor_done() before finishing the batch, the remaining
  * events will be returned again by another call pn_proactor_wait().  This is
@@ -108,21 +109,28 @@ int pn_proactor_listen(pn_proactor_t *, pn_listener_t *listener, const char *hos
  * handled in sequence, but batches returned by separate calls to
  * pn_proactor_wait() can be handled concurrently.
  */
-pn_event_batch_t *pn_proactor_wait(pn_proactor_t* d);
+pn_event_batch_t *pn_proactor_wait(pn_proactor_t *d);
 
 /**
- * Call when done handling events.
+ * Call when done handling a batch of events.
  *
  * Must be called exactly once to match each call to pn_proactor_wait().
  *
- * Thread safe: may be called from any thread provided the exactly once rules is
+ * Thread safe: may be called from any thread provided the exactly once rule is
  * respected.
  */
-void pn_proactor_done(pn_proactor_t* d, pn_event_batch_t *events);
+void pn_proactor_done(pn_proactor_t *d, pn_event_batch_t *events);
 
 /**
- * Cause PN_PROACTOR_INTERRUPT to be returned to exactly one thread calling wait()
- * for each call to pn_proactor_interrupt(). Thread safe.
+ * Cause PN_PROACTOR_INTERRUPT to be returned to exactly one call of
+ * pn_proactor_wait().
+ *
+ * If threads are blocked in pn_proactor_wait(), one of them will be
+ * interrupted, otherwise the interrupt will be returned by a future call to
+ * pn_proactor_wait(). Calling pn_proactor_interrupt() N times will return
+ * PN_PROACTOR_INTERRUPT to N current or future calls of pn_proactor_wait()
+ *
+ * Thread safe.
  */
 void pn_proactor_interrupt(pn_proactor_t* d);
 
@@ -131,8 +139,9 @@ void pn_proactor_interrupt(pn_proactor_t* d);
  * timeout milliseconds. Thread safe.
  *
  * Note calling pn_proactor_set_timeout() again before the PN_PROACTOR_TIMEOUT is
- * delivered will cancel the previous timeout and deliver an event only after
- * the new timeout.
+  *delivered will cancel the previous timeout and deliver an event only after
+ * the new timeout. ::pn_proactor_set_timeout(0) will cancel the timeout
+ * without setting a new one.
  */
 void pn_proactor_set_timeout(pn_proactor_t* d, pn_millis_t timeout);
 
@@ -140,7 +149,7 @@ void pn_proactor_set_timeout(pn_proactor_t* d, pn_millis_t timeout);
  * Cause a PN_CONNECTION_WAKE event to be returned by the proactor, even if
  * there are no IO events pending for the connection.
  *
- * Thread safe: this is the only pn_connection_ function that can be
+ * **Thread safe**: this is the only pn_connection_ function that can be
  * called concurrently.
  *
  * Wakes can be "coalesced" - if several pn_connection_wake() calls happen


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org