00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_timer_queue.h 1642 2010-04-08 13:37:57Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_TIMER_QUEUE_H 00020 #define APT_TIMER_QUEUE_H 00021 00022 /** 00023 * @file apt_timer_queue.h 00024 * @brief Timer Queue 00025 */ 00026 00027 #include "apt.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 /** Opaque timer declaration */ 00032 typedef struct apt_timer_t apt_timer_t; 00033 /** Opaque timer queue declaration */ 00034 typedef struct apt_timer_queue_t apt_timer_queue_t; 00035 00036 /** Prototype of timer callback */ 00037 typedef void (*apt_timer_proc_f)(apt_timer_t *timer, void *obj); 00038 00039 00040 /** Create timer queue */ 00041 APT_DECLARE(apt_timer_queue_t*) apt_timer_queue_create(apr_pool_t *pool); 00042 00043 /** Destroy timer queue */ 00044 APT_DECLARE(void) apt_timer_queue_destroy(apt_timer_queue_t *timer_queue); 00045 00046 /** Advance scheduled timers */ 00047 APT_DECLARE(void) apt_timer_queue_advance(apt_timer_queue_t *timer_queue, apr_uint32_t elapsed_time); 00048 00049 /** Is timer queue empty */ 00050 APT_DECLARE(apt_bool_t) apt_timer_queue_is_empty(const apt_timer_queue_t *timer_queue); 00051 00052 /** Get current timeout */ 00053 APT_DECLARE(apt_bool_t) apt_timer_queue_timeout_get(const apt_timer_queue_t *timer_queue, apr_uint32_t *timeout); 00054 00055 00056 /** Create timer */ 00057 APT_DECLARE(apt_timer_t*) apt_timer_create(apt_timer_queue_t *timer_queue, apt_timer_proc_f proc, void *obj, apr_pool_t *pool); 00058 00059 /** Set one-shot timer */ 00060 APT_DECLARE(apt_bool_t) apt_timer_set(apt_timer_t *timer, apr_uint32_t timeout); 00061 00062 /** Kill timer */ 00063 APT_DECLARE(apt_bool_t) apt_timer_kill(apt_timer_t *timer); 00064 00065 00066 APT_END_EXTERN_C 00067 00068 #endif /* APT_TIMER_QUEUE_H */