You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/22 01:17:08 UTC

[09/27] incubator-mynewt-core git commit: ocf_sample, oicmgr; no need to poll oci with calls to oc_main_loop().

ocf_sample, oicmgr; no need to poll oci with calls to oc_main_loop().


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/7f841e0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7f841e0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7f841e0d

Branch: refs/heads/develop
Commit: 7f841e0d0efb1442df64b356e1dba52bcded6e46
Parents: f5f9ef5
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 17 18:07:16 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 21 17:15:48 2016 -0800

----------------------------------------------------------------------
 apps/ocf_sample/src/main.c | 40 +++++-----------------------------------
 mgmt/oicmgr/src/oicmgr.c   | 17 -----------------
 2 files changed, 5 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f841e0d/apps/ocf_sample/src/main.c
----------------------------------------------------------------------
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index e423863..096b444 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -39,13 +39,7 @@
 #define OCF_MAIN_TASK_STACK_SIZE    (OS_STACK_ALIGN(512))
 static os_stack_t ocf_stack[OCF_MAIN_TASK_STACK_SIZE];
 struct os_task ocf_main_task;
-
-/** Auxilliary task for handling events from library packages. */
-#define OCF_AUX_TASK_PRIO           (9)
-#define OCF_AUX_TASK_STACK_SIZE     (OS_STACK_ALIGN(336))
-struct os_eventq ocf_aux_evq;
-static os_stack_t ocf_aux_stack[OCF_AUX_TASK_STACK_SIZE];
-struct os_task ocf_aux_task;
+struct os_eventq ocf_main_evq;
 
 #if (MYNEWT_VAL(OC_CLIENT) == 1)
 static void issue_requests(void);
@@ -230,38 +224,19 @@ oc_handler_t ocf_handler = {
 #endif
  };
 
-struct os_sem ocf_main_loop_sem;
-
-void
-oc_signal_main_loop(void)
-{
-     os_sem_release(&ocf_main_loop_sem);
-}
-
 static void
 ocf_main_task_handler(void *arg)
 {
-    os_sem_init(&ocf_main_loop_sem, 1);
-
 #if (MYNEWT_VAL(OC_CLIENT) == 1)
-    os_callout_init(&callout, &ocf_aux_evq, stop_observe, NULL);
+    os_callout_init(&callout, &ocf_main_evq, stop_observe, NULL);
 #endif
     while (1) {
-        oc_main_poll();
-        os_sem_pend(&ocf_main_loop_sem, OS_TIMEOUT_NEVER);
+        os_eventq_run(&ocf_main_evq);
     }
     oc_main_shutdown();
 }
 
 static void
-ocf_aux_task_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&ocf_aux_evq);
-    }
-}
-
-static void
 ocf_init_tasks(void)
 {
     int rc;
@@ -272,17 +247,12 @@ ocf_init_tasks(void)
     assert(rc == 0);
 
     /* Initialize eventq */
-    os_eventq_init(&ocf_aux_evq);
+    os_eventq_init(&ocf_main_evq);
 
     /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&ocf_aux_evq);
+    os_eventq_dflt_set(&ocf_main_evq);
 
     oc_main_init(&ocf_handler);
-
-    rc = os_task_init(&ocf_aux_task, "ocf_aux", ocf_aux_task_handler, NULL,
-            OCF_AUX_TASK_PRIO, OS_WAIT_FOREVER, ocf_aux_stack,
-            OCF_AUX_TASK_STACK_SIZE);
-    assert(rc == 0);
 }
 
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f841e0d/mgmt/oicmgr/src/oicmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index 4557189..e084caf 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -48,7 +48,6 @@ struct omgr_state {
 };
 
 static void omgr_event_start(struct os_event *ev);
-static void omgr_process_oc_event(struct os_event *ev);
 
 static struct omgr_state omgr_state = {
     .os_event.ev_cb = omgr_event_start,
@@ -219,21 +218,6 @@ static const oc_handler_t omgr_oc_handler = {
     .register_resources = omgr_register_resources
 };
 
-void
-oc_signal_main_loop(void)
-{
-    struct omgr_state *o = &omgr_state;
-
-    assert(o->os_evq); /* Must call mgmt_evq_set() first. */
-    os_eventq_put(o->os_evq, &o->os_event);
-}
-
-static void
-omgr_process_oc_event(struct os_event *ev)
-{
-    oc_main_poll();
-}
-
 static void
 omgr_event_start(struct os_event *ev)
 {
@@ -241,7 +225,6 @@ omgr_event_start(struct os_event *ev)
 
     oc_main_init((oc_handler_t *)&omgr_oc_handler);
     os_eventq_ensure(&o->os_evq, NULL);
-    o->os_event.ev_cb = omgr_process_oc_event;
 }
 
 int