__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef ISC_TIMER_H
#define ISC_TIMER_H 1
/*****
***** Module Info
*****/
/*! \file isc/timer.h
* \brief Provides timers which are event sources in the task system.
*
* Three types of timers are supported:
*
*\li 'ticker' timers generate a periodic tick event.
*
*\li 'once' timers generate an idle timeout event if they are idle for too
* long, and generate a life timeout event if their lifetime expires.
* They are used to implement both (possibly expiring) idle timers and
* 'one-shot' timers.
*
*\li 'limited' timers generate a periodic tick event until they reach
* their lifetime when they generate a life timeout event.
*
*\li 'inactive' timers generate no events.
*
* Timers can change type. It is typical to create a timer as
* an 'inactive' timer and then change it into a 'ticker' or
* 'once' timer.
*
*\li MP:
* The module ensures appropriate synchronization of data structures it
* creates and manipulates.
* Clients of this module must not be holding a timer's task's lock when
* making a call that affects that timer. Failure to follow this rule
* can result in deadlock.
* The caller must ensure that isc_timermgr_destroy() is called only
* once for a given manager.
*
* \li Reliability:
* No anticipated impact.
*
* \li Resources:
* TBS
*
* \li Security:
* No anticipated impact.
*
* \li Standards:
* None.
*/
/***
*** Imports
***/
#include <isc/types.h>
#include <isc/event.h>
#include <isc/eventclass.h>
#include <isc/lang.h>
#include <isc/time.h>
ISC_LANG_BEGINDECLS
/***
*** Types
***/
/*% Timer Type */
typedef enum {
isc_timertype_undefined = -1, /*%< Undefined */
isc_timertype_ticker = 0, /*%< Ticker */
isc_timertype_once = 1, /*%< Once */
isc_timertype_limited = 2, /*%< Limited */
isc_timertype_inactive = 3 /*%< Inactive */
} isc_timertype_t;
typedef struct isc_timerevent {
struct isc_event common;
isc_time_t due;
} isc_timerevent_t;
#define ISC_TIMEREVENT_FIRSTEVENT (ISC_EVENTCLASS_TIMER + 0)
#define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1)
#define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2)
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
/*% Timer and timer manager methods */
typedef struct {
void (*destroy)(isc_timermgr_t **managerp);
isc_result_t (*timercreate)(isc_timermgr_t *manager,
isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
isc_task_t *task,
isc_taskaction_t action,
void *arg,
isc_timer_t **timerp);
} isc_timermgrmethods_t;
typedef struct {
void (*attach)(isc_timer_t *timer, isc_timer_t **timerp);
void (*detach)(isc_timer_t **timerp);
isc_result_t (*reset)(isc_timer_t *timer, isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
isc_boolean_t purge);
isc_result_t (*touch)(isc_timer_t *timer);
} isc_timermethods_t;
/*%
* This structure is actually just the common prefix of a timer manager
* object implementation's version of an isc_timermgr_t.
* \brief
* Direct use of this structure by clients is forbidden. timer implementations
* may change the structure. 'magic' must be ISCAPI_TIMERMGR_MAGIC for any
* of the isc_timer_ routines to work. timer implementations must maintain
* all timer invariants.
*/
struct isc_timermgr {
unsigned int impmagic;
unsigned int magic;
isc_timermgrmethods_t *methods;
};
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
#define ISCAPI_TIMERMGR_VALID(m) ((m) != NULL && \
(m)->magic == ISCAPI_TIMERMGR_MAGIC)
/*%
* This is the common prefix of a timer object. The same note as
* that for the timermgr structure applies.
*/
struct isc_timer {
unsigned int impmagic;
unsigned int magic;
isc_timermethods_t *methods;
};
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
#define ISCAPI_TIMER_VALID(s) ((s) != NULL && \
(s)->magic == ISCAPI_TIMER_MAGIC)
/***
*** Timer and Timer Manager Functions
***
*** Note: all Ensures conditions apply only if the result is success for
*** those functions which return an isc_result_t.
***/
isc_result_t
isc_timer_create(isc_timermgr_t *manager,
isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
isc_task_t *task,
isc_taskaction_t action,
void *arg,
isc_timer_t **timerp);
/*%<
* Create a new 'type' timer managed by 'manager'. The timers parameters
* are specified by 'expires' and 'interval'. Events will be posted to
* 'task' and when dispatched 'action' will be called with 'arg' as the
* arg value. The new timer is returned in 'timerp'.
*
* Notes:
*
*\li For ticker timers, the timer will generate a 'tick' event every
* 'interval' seconds. The value of 'expires' is ignored.
*
*\li For once timers, 'expires' specifies the time when a life timeout
* event should be generated. If 'expires' is 0 (the epoch), then no life
* timeout will be generated. 'interval' specifies how long the timer
* can be idle before it generates an idle timeout. If 0, then no
* idle timeout will be generated.
*
*\li If 'expires' is NULL, the epoch will be used.
*
* If 'interval' is NULL, the zero interval will be used.
*
* Requires:
*
*\li 'manager' is a valid manager
*
*\li 'task' is a valid task
*
*\li 'action' is a valid action
*
*\li 'expires' points to a valid time, or is NULL.
*
*\li 'interval' points to a valid interval, or is NULL.
*
*\li type == isc_timertype_inactive ||
* ('expires' and 'interval' are not both 0)
*
*\li 'timerp' is a valid pointer, and *timerp == NULL
*
* Ensures:
*
*\li '*timerp' is attached to the newly created timer
*
*\li The timer is attached to the task
*
*\li An idle timeout will not be generated until at least Now + the
* timer's interval if 'timer' is a once timer with a non-zero
* interval.
*
* Returns:
*
*\li Success
*\li No memory
*\li Unexpected error
*/
isc_result_t
isc_timer_reset(isc_timer_t *timer,
isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
isc_boolean_t purge);
/*%<
* Change the timer's type, expires, and interval values to the given
* values. If 'purge' is TRUE, any pending events from this timer
* are purged from its task's event queue.
*
* Notes:
*
*\li If 'expires' is NULL, the epoch will be used.
*
*\li If 'interval' is NULL, the zero interval will be used.
*
* Requires:
*
*\li 'timer' is a valid timer
*
*\li The same requirements that isc_timer_create() imposes on 'type',
* 'expires' and 'interval' apply.
*
* Ensures:
*
*\li An idle timeout will not be generated until at least Now + the
* timer's interval if 'timer' is a once timer with a non-zero
* interval.
*
* Returns:
*
*\li Success
*\li No memory
*\li Unexpected error
*/
isc_result_t
isc_timer_touch(isc_timer_t *timer);
/*%<
* Set the last-touched time of 'timer' to the current time.
*
* Requires:
*
*\li 'timer' is a valid once timer.
*
* Ensures:
*
*\li An idle timeout will not be generated until at least Now + the
* timer's interval if 'timer' is a once timer with a non-zero
* interval.
*
* Returns:
*
*\li Success
*\li Unexpected error
*/
void
isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp);
/*%<
* Attach *timerp to timer.
*
* Requires:
*
*\li 'timer' is a valid timer.
*
*\li 'timerp' points to a NULL timer.
*
* Ensures:
*
*\li *timerp is attached to timer.
*/
void
isc_timer_detach(isc_timer_t **timerp);
/*%<
* Detach *timerp from its timer.
*
* Requires:
*
*\li 'timerp' points to a valid timer.
*
* Ensures:
*
*\li *timerp is NULL.
*
*\li If '*timerp' is the last reference to the timer,
* then:
*
*\code
* The timer will be shutdown
*
* The timer will detach from its task
*
* All resources used by the timer have been freed
*
* Any events already posted by the timer will be purged.
* Therefore, if isc_timer_detach() is called in the context
* of the timer's task, it is guaranteed that no more
* timer event callbacks will run after the call.
*\endcode
*/
isc_timertype_t
isc_timer_gettype(isc_timer_t *timer);
/*%<
* Return the timer type.
*
* Requires:
*
*\li 'timer' to be a valid timer.
*/
isc_result_t
isc_timermgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
isc_timermgr_t **managerp);
isc_result_t
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
/*%<
* Create a timer manager. isc_timermgr_createinctx() also associates
* the new manager with the specified application context.
*
* Notes:
*
*\li All memory will be allocated in memory context 'mctx'.
*
* Requires:
*
*\li 'mctx' is a valid memory context.
*
*\li 'managerp' points to a NULL isc_timermgr_t.
*
*\li 'actx' is a valid application context (for createinctx()).
*
* Ensures:
*
*\li '*managerp' is a valid isc_timermgr_t.
*
* Returns:
*
*\li Success
*\li No memory
*\li Unexpected error
*/
void
isc_timermgr_destroy(isc_timermgr_t **managerp);
/*%<
* Destroy a timer manager.
*
* Notes:
*
*\li This routine blocks until there are no timers left in the manager,
* so if the caller holds any timer references using the manager, it
* must detach them before calling isc_timermgr_destroy() or it will
* block forever.
*
* Requires:
*
*\li '*managerp' is a valid isc_timermgr_t.
*
* Ensures:
*
*\li *managerp == NULL
*
*\li All resources used by the manager have been freed.
*/
void isc_timermgr_poke(isc_timermgr_t *m);
/*%<
* See isc_timermgr_create() above.
*/
typedef isc_result_t
(*isc_timermgrcreatefunc_t)(isc_mem_t *mctx, isc_timermgr_t **managerp);
isc_result_t
isc__timer_register(void);
/*%<
* Register a new timer management implementation and add it to the list of
* supported implementations. This function must be called when a different
* event library is used than the one contained in the ISC library.
*/
isc_result_t
isc_timer_register(isc_timermgrcreatefunc_t createfunc);
/*%<
* A short cut function that specifies the timer management module in the ISC
* library for isc_timer_register(). An application that uses the ISC library
* usually do not have to care about this function: it would call
* isc_lib_register(), which internally calls this function.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_TIMER_H */
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| aes.h | File | 1.05 KB | 0644 |
|
| app.h | File | 10.23 KB | 0644 |
|
| assertions.h | File | 2.78 KB | 0644 |
|
| atomic.h | File | 4.15 KB | 0644 |
|
| backtrace.h | File | 3.8 KB | 0644 |
|
| base32.h | File | 3.94 KB | 0644 |
|
| base64.h | File | 2.39 KB | 0644 |
|
| bind9.h | File | 849 B | 0644 |
|
| boolean.h | File | 746 B | 0644 |
|
| buffer.h | File | 25.69 KB | 0644 |
|
| bufferlist.h | File | 1.42 KB | 0644 |
|
| commandline.h | File | 1.69 KB | 0644 |
|
| condition.h | File | 1.44 KB | 0644 |
|
| counter.h | File | 1.88 KB | 0644 |
|
| crc64.h | File | 986 B | 0644 |
|
| deprecated.h | File | 622 B | 0644 |
|
| dir.h | File | 1.96 KB | 0644 |
|
| entropy.h | File | 8.76 KB | 0644 |
|
| errno.h | File | 658 B | 0644 |
|
| errno2result.h | File | 893 B | 0644 |
|
| error.h | File | 1.4 KB | 0644 |
|
| event.h | File | 2.98 KB | 0644 |
|
| eventclass.h | File | 1.35 KB | 0644 |
|
| file.h | File | 11.43 KB | 0644 |
|
| formatcheck.h | File | 892 B | 0644 |
|
| fsaccess.h | File | 7.25 KB | 0644 |
|
| hash.h | File | 7.52 KB | 0644 |
|
| heap.h | File | 5.14 KB | 0644 |
|
| hex.h | File | 2.33 KB | 0644 |
|
| hmacmd5.h | File | 1.75 KB | 0644 |
|
| hmacsha.h | File | 4.44 KB | 0644 |
|
| ht.h | File | 3.42 KB | 0644 |
|
| httpd.h | File | 2.26 KB | 0644 |
|
| int.h | File | 1.37 KB | 0644 |
|
| interfaceiter.h | File | 3.03 KB | 0644 |
|
| iterated_hash.h | File | 1.02 KB | 0644 |
|
| json.h | File | 1.42 KB | 0644 |
|
| keyboard.h | File | 976 B | 0644 |
|
| lang.h | File | 636 B | 0644 |
|
| lex.h | File | 9.42 KB | 0644 |
|
| lfsr.h | File | 2.88 KB | 0644 |
|
| lib.h | File | 1.04 KB | 0644 |
|
| likely.h | File | 718 B | 0644 |
|
| list.h | File | 5.65 KB | 0644 |
|
| log.h | File | 28.06 KB | 0644 |
|
| magic.h | File | 993 B | 0644 |
|
| md5.h | File | 2.34 KB | 0644 |
|
| mem.h | File | 20.63 KB | 0644 |
|
| meminfo.h | File | 690 B | 0644 |
|
| msgcat.h | File | 2.66 KB | 0644 |
|
| msgs.h | File | 8.22 KB | 0644 |
|
| mutex.h | File | 3.44 KB | 0644 |
|
| mutexblock.h | File | 1.34 KB | 0644 |
|
| net.h | File | 10.32 KB | 0644 |
|
| netaddr.h | File | 4.56 KB | 0644 |
|
| netdb.h | File | 862 B | 0644 |
|
| netscope.h | File | 947 B | 0644 |
|
| offset.h | File | 699 B | 0644 |
|
| once.h | File | 981 B | 0644 |
|
| ondestroy.h | File | 2.79 KB | 0644 |
|
| os.h | File | 670 B | 0644 |
|
| parseint.h | File | 1.49 KB | 0644 |
|
| platform.h | File | 9.31 KB | 0644 |
|
| pool.h | File | 3.42 KB | 0644 |
|
| portset.h | File | 3.21 KB | 0644 |
|
| print.h | File | 2.49 KB | 0644 |
|
| queue.h | File | 4.66 KB | 0644 |
|
| quota.h | File | 2.29 KB | 0644 |
|
| radix.h | File | 6.37 KB | 0644 |
|
| random.h | File | 2.99 KB | 0644 |
|
| ratelimiter.h | File | 3.38 KB | 0644 |
|
| refcount.h | File | 7.89 KB | 0644 |
|
| regex.h | File | 766 B | 0644 |
|
| region.h | File | 1.99 KB | 0644 |
|
| resource.h | File | 2.8 KB | 0644 |
|
| result.h | File | 4.62 KB | 0644 |
|
| resultclass.h | File | 1.56 KB | 0644 |
|
| rwlock.h | File | 3.6 KB | 0644 |
|
| safe.h | File | 1.21 KB | 0644 |
|
| serial.h | File | 1.4 KB | 0644 |
|
| sha1.h | File | 1.52 KB | 0644 |
|
| sha2.h | File | 5.65 KB | 0644 |
|
| sockaddr.h | File | 6 KB | 0644 |
|
| socket.h | File | 35.81 KB | 0644 |
|
| stat.h | File | 805 B | 0644 |
|
| stats.h | File | 3.02 KB | 0644 |
|
| stdio.h | File | 1.74 KB | 0644 |
|
| stdlib.h | File | 703 B | 0644 |
|
| stdtime.h | File | 1.3 KB | 0644 |
|
| strerror.h | File | 776 B | 0644 |
|
| string.h | File | 5.94 KB | 0644 |
|
| symtab.h | File | 4.21 KB | 0644 |
|
| syslog.h | File | 843 B | 0644 |
|
| task.h | File | 20.97 KB | 0644 |
|
| taskpool.h | File | 3.61 KB | 0644 |
|
| thread.h | File | 1.47 KB | 0644 |
|
| time.h | File | 8.66 KB | 0644 |
|
| timer.h | File | 10.54 KB | 0644 |
|
| tm.h | File | 894 B | 0644 |
|
| types.h | File | 5.54 KB | 0644 |
|
| util.h | File | 7.49 KB | 0644 |
|
| version.h | File | 688 B | 0644 |
|
| xml.h | File | 1.07 KB | 0644 |
|