event.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_EVENT_H
10 #define SQUID_EVENT_H
11 
12 #include "AsyncEngine.h"
13 #include "base/Packable.h"
14 #include "mem/forward.h"
15 
16 /* event scheduling facilities - run a callback after a given time period. */
17 
18 typedef void EVH(void *);
19 
20 void eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata=true);
21 void eventAddIsh(const char *name, EVH * func, void *arg, double delta_ish, int);
22 void eventDelete(EVH * func, void *arg);
23 void eventInit(void);
24 void eventFreeMemory(void);
25 int eventFind(EVH *, void *);
26 
27 class ev_entry
28 {
30 
31 public:
32  ev_entry(char const * name, EVH * func, void *arg, double when, int weight, bool cbdata=true);
33  ~ev_entry();
34  const char *name;
36  void *arg;
37  double when;
38 
39  int weight;
40  bool cbdata;
41 
43 };
44 
45 // manages time-based events
47 {
48 
49 public:
52  /* cancel a scheduled but not dispatched event */
53  void cancel(EVH * func, void * arg);
54  /* clean up the used memory in the scheduler */
55  void clean();
56  /* either EVENT_IDLE or milliseconds remaining until the next event */
57  int timeRemaining() const;
58  /* cache manager output for the event queue */
59  void dump(Packable *);
60  /* find a scheduled event */
61  bool find(EVH * func, void * arg);
62  /* schedule a callback function to run in when seconds */
63  void schedule(const char *name, EVH * func, void *arg, double when, int weight, bool cbdata=true);
64  int checkEvents(int timeout);
65  static EventScheduler *GetInstance();
66 
67 private:
70 };
71 
72 #endif /* SQUID_EVENT_H */
73 
EVH * func
Definition: event.h:35
void eventFreeMemory(void)
Definition: event.cc:148
ev_entry * next
Definition: event.h:42
void eventDelete(EVH *func, void *arg)
Definition: event.cc:130
void eventAddIsh(const char *name, EVH *func, void *arg, double delta_ish, int)
Definition: event.cc:115
ev_entry(char const *name, EVH *func, void *arg, double when, int weight, bool cbdata=true)
Definition: event.cc:90
void eventInit(void)
Definition: event.cc:136
int checkEvents(int timeout)
Definition: event.cc:225
void dump(Packable *)
Definition: event.cc:270
EventScheduler()
Definition: event.cc:161
Definition: cbdata.cc:60
bool find(EVH *func, void *arg)
Definition: event.cc:289
~EventScheduler()
Definition: event.cc:164
static EventScheduler * GetInstance()
Definition: event.cc:303
void * arg
Definition: event.h:36
int timeRemaining() const
Definition: event.cc:208
~ev_entry()
Definition: event.cc:101
Definition: event.h:28
void eventAdd(const char *name, EVH *func, void *arg, double when, int, bool cbdata=true)
Definition: event.cc:108
void schedule(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata=true)
Definition: event.cc:309
void EVH(void *)
Definition: event.h:18
int weight
Definition: event.h:39
double when
Definition: event.h:37
ev_entry * tasks
Definition: event.h:69
void cancel(EVH *func, void *arg)
Definition: event.cc:170
static EventScheduler _instance
Definition: event.h:68
MEMPROXY_CLASS(ev_entry)
const char * name
Definition: event.h:34
bool cbdata
Definition: event.h:40
void clean()
Definition: event.cc:259
int eventFind(EVH *, void *)
Definition: event.cc:154

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors