1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include <nks/errno.h>
20
#include "apr_private.h"
21
#include "apr_general.h"
22
#include "apr_strings.h"
23
#include "apr_arch_thread_mutex.h"
24
#include "apr_arch_thread_cond.h"
25
#include "apr_portable.h"
27
static apr_status_t thread_cond_cleanup(void *data)
29
apr_thread_cond_t *cond = (apr_thread_cond_t *)data;
31
NXCondFree(cond->cond);
35
APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
38
apr_thread_cond_t *new_cond = NULL;
40
new_cond = (apr_thread_cond_t *)apr_pcalloc(pool, sizeof(apr_thread_cond_t));
45
new_cond->pool = pool;
47
new_cond->cond = NXCondAlloc(NULL);
49
if(new_cond->cond == NULL)
52
apr_pool_cleanup_register(new_cond->pool, new_cond,
53
(void*)thread_cond_cleanup,
54
apr_pool_cleanup_null);
59
APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
60
apr_thread_mutex_t *mutex)
62
if (NXCondWait(cond->cond, mutex->mutex) != 0)
67
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
68
apr_thread_mutex_t *mutex,
69
apr_interval_time_t timeout){
70
if (NXCondTimedWait(cond->cond, mutex->mutex,
71
(timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) {
77
APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
79
NXCondSignal(cond->cond);
83
APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
85
NXCondBroadcast(cond->cond);
89
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
92
if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) {
93
apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup);
99
APR_POOL_IMPLEMENT_ACCESSOR(thread_cond)