source: trunk/libtransmission/publish.h @ 7528

Last change on this file since 7528 was 7528, checked in by charles, 12 years ago

(trunk libT) avoid some unnecessary memory fragmentation... for composited objects that have a tr_publisher, contain the it directly rather than a pointer to one allocated elsewhere on the heap.

  • Property svn:keywords set to Date Rev Author Id
File size: 1.6 KB
Line 
1/*
2 * This file Copyright (C) 2007-2008 Charles Kerr <charles@transmissionbt.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: publish.h 7528 2008-12-29 18:10:07Z charles $
11 */
12
13#ifndef __TRANSMISSION__
14#error only libtransmission should #include this header.
15#endif
16
17#ifndef _TR_PUBLISHER_H_
18#define _TR_PUBLISHER_H_
19
20struct tr_list;
21
22/**
23***  A lightweight implementation of the 'Observable' design pattern.
24**/
25
26typedef struct tr_publisher
27{
28    struct tr_list * list;
29}
30tr_publisher;
31
32typedef void * tr_publisher_tag;
33
34typedef void tr_delivery_func ( void * source,
35                                void * event,
36                                void * user_data );
37
38/**
39***  Observer API
40**/
41
42tr_publisher_tag tr_publisherSubscribe( tr_publisher   * publisher,
43                                        tr_delivery_func delivery_func,
44                                        void *           user_data );
45
46void             tr_publisherUnsubscribe( tr_publisher   * publisher,
47                                          tr_publisher_tag tag );
48
49/**
50***  Observable API
51**/
52
53extern const tr_publisher TR_PUBLISHER_INIT;
54
55void             tr_publisherDestruct( tr_publisher * );
56
57void             tr_publisherPublish( tr_publisher * publisher,
58                                      void *           source,
59                                      void *           event );
60
61#endif
Note: See TracBrowser for help on using the repository browser.