8b2613fa01514ca1cd33057ce3c3e0d4abe57ee4
[projects/modsched/linux.git] / framework / fw_comm.c
1 #include "fw_comm.h"
2
3 #include <fw.h>
4
5 fw_list_head_t topics[LAST-FIRST];
6
7 struct fw_topic_element {
8         fw_list_head_t list;
9         void *callback;
10 };
11
12
13 void fw_subscribe(topic_t topic, void *callback)
14 {
15         struct fw_topic_element *subscriber = fw_malloc(sizeof(struct fw_topic_element));
16         subscriber->callback = callback;
17
18         fw_list_add_tail(&subscriber->list, &topics[topic]);
19 }
20
21 void fw_notify(topic_t topic, void *data)
22 {
23         struct fw_topic_element *iter;
24
25         fw_list_for_each_entry(iter, &topics[topic], list)
26                 ((void (*)(void *))iter->callback)(data);
27 }
28
29 void fw_init_comm()
30 {
31         int i;
32
33         for(i=FIRST;i<LAST;i++){
34                 FW_LIST_INIT(topics[i]);
35         }
36 }