chiark / gitweb /
Started to do multithreading, but was using fundamentally incorrect
[adns] / src / adns-mt.h
1 /*
2  * adnsmt.h
3  * - adns multi-threaded API
4  */
5 /*
6  *  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
7  *  
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *  
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *  
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software Foundation,
20  *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  *  $Id$
23  */
24
25 #ifndef ADNSMT_H_INCLUDED
26 #define ADNSMT_H_INCLUDED
27
28 #include <adns.h>
29
30 typedef struct adns_mt__state *adns_mt_state;
31 typedef struct adns_mt__query *adns_mt_query;
32
33 int adns_mt_init(adns_mt_state *newstate_r, adns_initflags flags,
34                  FILE *diagfile /*0=>stderr*/);
35
36 int adns_mt_init_strcfg(adns_mt_state *newstate_r, adns_initflags flags,
37                         FILE *diagfile /*0=>discard*/, const char *configtext);
38
39 int adns_mt_synchronous(adns_mt_state adts,
40                         const char *owner,
41                         adns_rrtype type,
42                         adns_queryflags flags,
43                         adns_answer **answer_r);
44
45 int adns_mt_submit(adns_mt_state adts,
46                    const char *owner,
47                    adns_rrtype type,
48                    adns_queryflags flags,
49                    void *context,
50                    adns_mt_query *query_r);
51
52 int adns_mt_wait(adns_mt_state adts,
53                  adns_mt_query *query_io,
54                  adns_answer **answer_r,
55                  void **context_r);
56
57 void adns_mt_cancel(adns_mt_query query);
58 /* Do not cancel a query while another thread is waiting for it ! */
59
60 void adns_mt_finish(adns_mt_state);
61 /* You may call this even if you have queries outstanding;
62  * they will be cancelled.  NB the comment about _mt_cancel above.
63  */
64
65 #endif