Hi Joseph, It?s a good idea. In fact, there?s a ticket and hopefully a non-hacky solution on this. Please take a look at IOT-1828.
Thanks, Way From: Morrow, Joseph L<mailto:[email protected]> Sent: Friday, May 5, 2017 1:05 AM To: iotivity-dev at lists.iotivity.org<mailto:iotivity-dev at lists.iotivity.org> Subject: [dev] Make OCProcess() a blocking call.. Save CPU cycles. (From 100% CPU core usage to ~0%.) Hi, I just did some playing around to see what the ramifications to wait for the CA layer to tell the application layer when to call OCProcess(). This would save you from eating a core of your processor polling on OCProcess(). On multi-threaded platforms, IoTivity?s Connectivity Abstraction layer sleeps unless there is data on the send/recv buffers. So it would make sense for the application layer to sleep it?s IoTivity thread as well. Check out my hacky changeset here: https://gerrit.iotivity.org/gerrit/#/c/19653/<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgerrit.iotivity.org%2Fgerrit%2F%23%2Fc%2F19653%2F&data=02%7C01%7CWayakorn.Vadhanasin%40microsoft.com%7Ce5dab154025c4694ea2d08d4938d76e1%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636295683201768801&sdata=B7OoXlsoLaHbhXmWjeAVh%2FK2Ho7AXn25ah58W01sMf8%3D&reserved=0> Note: I?ve tested with <iotivity>/resource/csdk/stack/samples/linux/SimpleClientServer/ocerver.cpp on branch 1.2.1. Feel free to build on this idea. Or offer some advice on the best way forward. Using ?extern? like I am is certainly not appropriate for an end API. Although? We could wrap my logic with ?ifndef SINGLE_THREADED?. Alas, it?s too hacky. Thanks, Joey Morrow -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20170505/99b883ac/attachment.html>
