MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Functions | Variables
event.c File Reference
#include "event.h"
#include <stdlib.h>
#include <string.h>
Include dependency graph for event.c:

Go to the source code of this file.

Functions

int event_listen (EventSpec *eh, eventfunc func, void *userdata)
 
int event_unlisten (EventSpec *eh, eventfunc func, void *userdata)
 
int event_emit (EventSpec *eh, EIBase *event)
 

Variables

EventSpec EventSlotsFork = {"SlotsFork", 0, {{0}}}
 
EventSpec EventSlotsAfterGC = {"SlotsAfterGC", 0, {{0}}}
 

Function Documentation

◆ event_emit()

int event_emit ( EventSpec eh,
EIBase event 
)

Definition at line 44 of file event.c.

45 {
46 
47  int i;
48  for(i = 0; i < eh->used; i ++) {
49  eh->h[i].func(event, eh->h[i].userdata);
50  }
51  return 0;
52 }
eventfunc func
Definition: event.h:16
void * userdata
Definition: event.h:17
int used
Definition: event.h:25
EventHandler h[MAXEH]
Definition: event.h:26

References EventHandler::func, EventSpec::h, EventSpec::used, and EventHandler::userdata.

Referenced by slots_split_particle().

Here is the caller graph for this function:

◆ event_listen()

int event_listen ( EventSpec eh,
eventfunc  func,
void *  userdata 
)

Definition at line 6 of file event.c.

7 {
8  int i;
9  for(i = 0; i < eh->used; i ++) {
10  if(eh->h[i].func == func && eh->h[i].userdata == userdata) {
11  return 0;
12  }
13  }
14  if(eh->used == MAXEH) {
15  /* overflown */
16  abort();
17  }
18 
19  eh->h[eh->used].func = func;
20  eh->h[eh->used].userdata = userdata;
21  eh->used ++;
22  return 0;
23 }
#define MAXEH
Definition: event.h:20

References EventHandler::func, EventSpec::h, MAXEH, EventSpec::used, and EventHandler::userdata.

Referenced by force_tree_rebuild(), and rebuild_activelist().

Here is the caller graph for this function:

◆ event_unlisten()

int event_unlisten ( EventSpec eh,
eventfunc  func,
void *  userdata 
)

Definition at line 26 of file event.c.

27 {
28  int i;
29  for(i = 0; i < eh->used; i ++) {
30  if(eh->h[i].func == func && eh->h[i].userdata == userdata) {
31  break;
32  }
33  }
34  if(i == eh->used || eh->used == 0) {
35  return 1;
36  }
37  memmove(&eh->h[i], &eh->h[i+1], sizeof(eh->h[0]) * (eh->used - i - 1));
38  eh->used --;
39  return 0;
40 }

References EventHandler::func, EventSpec::h, EventSpec::used, and EventHandler::userdata.

Referenced by force_tree_free(), and free_activelist().

Here is the caller graph for this function:

Variable Documentation

◆ EventSlotsAfterGC

EventSpec EventSlotsAfterGC = {"SlotsAfterGC", 0, {{0}}}

Definition at line 55 of file event.c.

◆ EventSlotsFork

EventSpec EventSlotsFork = {"SlotsFork", 0, {{0}}}