summaryrefslogtreecommitdiffstats
blob: 0cdd1632a5388c3c37e49f06645195b260f6eddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <ares.h>
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <list>

#include "Swiften/Network/DomainNameResolver.h"

namespace Swift {
	class CAresQuery;

	class CAresDomainNameResolver : public DomainNameResolver {
		public:
			CAresDomainNameResolver();
			~CAresDomainNameResolver();

			virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& name);
			virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& name);

		private:
			friend class CAresQuery;

			void run();
			void addToQueue(boost::shared_ptr<CAresQuery>);

		private:
			bool stopRequested;
			ares_channel channel;
			boost::thread* thread;
			boost::mutex pendingQueriesMutex;
			std::list< boost::shared_ptr<CAresQuery> > pendingQueries;
	};
}