Hi Gabriel,
Your requirement needs different concept of programming model from architecture
perspective.
Presumably, we can the wrapper API with semaphore logic on top of looping logic.
Anyway, we can find the same waiting logic in the C++ API Wrapper also.
(sleep/wait logic is used.)
void InProcServerWrapper::processFunc()
{
auto cLock = m_csdkLock.lock();
while(cLock && m_threadRun)
{
OCStackResult result;
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
result = OCProcess();
}
if(OC_STACK_ERROR == result)
{
oclog() << "OCProcess failed with result " << result
<<std::flush;
// ...the value of variable result is simply ignored for now.
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
BR, Uze Choi
From: iotivity-dev-bounces at lists.iotivity.org
[mailto:[email protected]] On Behalf Of Schulhof, Gabriel
Sent: Thursday, May 26, 2016 8:10 PM
To: iotivity-dev
Subject: [dev] Main loop operation
Hi!
With iotivity turning over in response to OCProcess(), how do I avoid calling
OCProcess() in vain? Right now, I have a timeout that calls it every 100 ms
(probably too often, but I can easily change that). Still, I'd like to avoid
making any unnecessary calls to it if at all possible. Is there a feedback
mechanism or notification mechanism that tells me that I need to call
OCProcess()?
TIA for your help and advice,
Gabriel
-------------- next part --------------
HTML ?????? ??????????????...
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160527/53fef044/attachment.html>