event.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 "mem/forward.h"
14 
15 class StoreEntry;
16 
17 /* event scheduling facilities - run a callback after a given time period. */
18 
19 typedef void EVH(void *);
20 
21 void eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata=true);
22 void eventAddIsh(const char *name, EVH * func, void *arg, double delta_ish, int);
23 void eventDelete(EVH * func, void *arg);
24 void eventInit(void);
25 void eventFreeMemory(void);
26 int eventFind(EVH *, void *);
27 
28 class ev_entry
29 {
31 
32 public:
33  ev_entry(char const * name, EVH * func, void *arg, double when, int weight, bool cbdata=true);
34  ~ev_entry();
35  const char *name;
37  void *arg;
38  double when;
39 
40  int weight;
41  bool cbdata;
42 
44 };
45 
46 // manages time-based events
48 {
49 
50 public:
53  /* cancel a scheduled but not dispatched event */
54  void cancel(EVH * func, void * arg);
55  /* clean up the used memory in the scheduler */
56  void clean();
57  /* either EVENT_IDLE or milliseconds remaining until the next event */
58  int timeRemaining() const;
59  /* cache manager output for the event queue */
60  void dump(StoreEntry *);
61  /* find a scheduled event */
62  bool find(EVH * func, void * arg);
63  /* schedule a callback function to run in when seconds */
64  void schedule(const char *name, EVH * func, void *arg, double when, int weight, bool cbdata=true);
65  int checkEvents(int timeout);
66  static EventScheduler *GetInstance();
67 
68 private:
71 };
72 
73 #endif /* SQUID_EVENT_H */
74 
EVH * func
Definition: event.h:36
Definition: cbdata.cc:60
ev_entry * next
Definition: event.h:43
Definition: event.h:28
void * arg
Definition: event.h:37
void EVH void double delta_ish
Definition: stub_event.cc:16
ev_entry * tasks
Definition: event.h:70
ev_entry(char const *name, EVH *func, void *arg, double when, int weight, bool cbdata=true)
Definition: event.cc:91
void clean()
Definition: event.cc:263
void eventDelete(EVH *func, void *arg)
Definition: event.cc:131
~EventScheduler()
Definition: event.cc:165
void EVH void * arg
Definition: stub_event.cc:16
void EVH(void *)
Definition: event.h:19
double when
Definition: event.h:38
int checkEvents(int timeout)
Definition: event.cc:226
void dump(StoreEntry *)
Definition: event.cc:274
void eventInit(void)
Definition: event.cc:137
int eventFind(EVH *, void *)
Definition: event.cc:155
void eventAdd(const char *name, EVH *func, void *arg, double when, int, bool cbdata=true)
Definition: event.cc:109
const char * name
Definition: event.h:35
int timeRemaining() const
Definition: event.cc:209
EventScheduler()
Definition: event.cc:162
static EventScheduler * GetInstance()
Definition: event.cc:311
bool find(EVH *func, void *arg)
Definition: event.cc:297
MEMPROXY_CLASS(ev_entry)
void eventFreeMemory(void)
Definition: event.cc:149
int weight
Definition: event.h:40
~ev_entry()
Definition: event.cc:102
void EVH * func
Definition: stub_event.cc:16
bool cbdata
Definition: event.h:41
static EventScheduler _instance
Definition: event.h:69
void eventAddIsh(const char *name, EVH *func, void *arg, double delta_ish, int)
Definition: event.cc:116
void schedule(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata=true)
Definition: event.cc:317
void cancel(EVH *func, void *arg)
Definition: event.cc:171

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors