BLE Host - Use os_eventq_poll()

Before, the host code implemented an eventq "peek" operation:
* disable interrupts
* check whether anything is on the eventq
* enable interrupts
* if something was on the queue, call os_eventq_get().

Unlike os_eventq_get(), os_eventq_poll() takes a timeout parameter.  Now
the host calls os_eventq_poll() with a timeout of 0 to perform a
non-blocking read of the eventq.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b187e6dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b187e6dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b187e6dc

Branch: refs/heads/develop
Commit: b187e6dc21e87ce3f4592786506793f132779c06
Parents: 24b90c3
Author: Christopher Collins <[email protected]>
Authored: Thu Aug 4 13:39:25 2016 -0700
Committer: Christopher Collins <[email protected]>
Committed: Thu Aug 4 13:39:25 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b187e6dc/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 8035b49..225b26c 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -330,17 +330,19 @@ static void
 ble_hs_event_handle(void *unused)
 {
     struct os_callout_func *cf;
+    struct os_eventq *evqp;
     struct os_event *ev;
     uint8_t *hci_evt;
-    os_sr_t sr;
     int rc;
     int i;
 
+    evqp = &ble_hs_evq;
+
     i = 0;
     while (1) {
         /* If the host has already processed several consecutive events, stop
          * and return control to the parent task.  Put an event on the parent
-         * task's eventq so indicate that more host events are enqueued.
+         * task's eventq to indicate that more host events are enqueued.
          */
         if (i >= BLE_HS_MAX_EVS_IN_A_ROW) {
             os_eventq_put(ble_hs_parent_evq, &ble_hs_event_co.cf_c.c_ev);
@@ -348,15 +350,11 @@ ble_hs_event_handle(void *unused)
         }
         i++;
 
-        OS_ENTER_CRITICAL(sr);
-        ev = STAILQ_FIRST(&ble_hs_evq.evq_list);
-        OS_EXIT_CRITICAL(sr);
-
+        ev = os_eventq_poll(&evqp, 1, 0);
         if (ev == NULL) {
             break;
         }
 
-        ev = os_eventq_get(&ble_hs_evq);
         switch (ev->ev_type) {
         case OS_EVENT_T_TIMER:
             cf = (struct os_callout_func *)ev;

Reply via email to