The CA thread pool APIs are not intended to be Public.
Change-Id: Ic212c453c82e639be9f611b4b16a712054475de6
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18987
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
static bool fExit = false;
static bool fExit = false;
-static ca_thread_pool_t g_threadPoolHandle = NULL;
+static oc_thread g_requestsThread = NULL;
static OCDevAddr endPoint;
static char token[1024] = "";
static char authProvider[1024] = DEFAULT_AUTH_PROVIDER;
static OCDevAddr endPoint;
static char token[1024] = "";
static char authProvider[1024] = DEFAULT_AUTH_PROVIDER;
printf(">> Entered Wrong Menu Number. Please Enter Again\n\n");
}
printf(">> Entered Wrong Menu Number. Please Enter Again\n\n");
}
-static void userRequests(void *data)
+static void *userRequests(void *data)
{
if (NULL == data)
{
OIC_LOG(ERROR, TAG, "Received NULL data");
{
if (NULL == data)
{
OIC_LOG(ERROR, TAG, "Received NULL data");
}
OCMode mode = *(OCMode*)data;
}
OCMode mode = *(OCMode*)data;
}
FILE* server_fopen(const char *path, const char *mode)
}
FILE* server_fopen(const char *path, const char *mode)
OCStackResult startRequestsThread(OCMode *mode)
{
OCStackResult startRequestsThread(OCMode *mode)
{
- CAResult_t res = ca_thread_pool_init(1, &g_threadPoolHandle);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "thread pool initialize error.");
- return res;
- }
+ OCThreadResult_t res = oc_thread_new(&g_requestsThread, userRequests, mode);
- res = ca_thread_pool_add_task(g_threadPoolHandle, userRequests, mode);
- if (CA_STATUS_OK != res)
+ if (OC_THREAD_SUCCESS != res)
- OIC_LOG(ERROR, TAG, "thread pool add task error.");
- ca_thread_pool_free(g_threadPoolHandle);
+ OIC_LOG_V(ERROR, TAG, "oc_thread_new failed - error %u", res);
+ return OC_STACK_NO_MEMORY;
}
OCStackResult initProcess(OCMode mode)
}
OCStackResult initProcess(OCMode mode)
void freeThreadResources()
{
void freeThreadResources()
{
- if (g_threadPoolHandle)
- ca_thread_pool_free(g_threadPoolHandle);
+ OCThreadResult_t res = oc_thread_wait(g_requestsThread);
+
+ if (OC_THREAD_SUCCESS != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "oc_thread_wait failed - error %u", res);
+ }
+
+ res = oc_thread_free(g_requestsThread);
+
+ if (OC_THREAD_SUCCESS != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "oc_thread_free failed - error %u", res);
+ }
+
+ g_requestsThread = NULL;