[Development] API review for a new QDnsResolver class
Jeremy Lainé
jeremy.laine at m4x.org
Wed Jan 4 17:51:42 CET 2012
Replying to myself to try and get the discussion going again.
A summary of API decisions so far:
- we only provide an asynchronous API
- we do not want a "manager" object (QNAM-style) to avoid users creating a manager per lookup
- we want a single class to support different types of DNS requests (Q3Dns-style)
- lookups are performed by calling static methods returning a pointer to a QObject-derived class, which emits the "finished()" signal upon completion
What remains to be decided:
- do we want shared pointers or not? My feeling is that using QSharedPointer is going to be awkward for the API user, I cannot find any other example of a Qt API which returns a QSharedPointer to a QObject-derived class.
- finalise the class name (I think QDns was suggested)
In the meantime, I have updated my implementation assuming we use raw pointers, with QDnsReply as the working name for the class:
https://qt.gitorious.org/~sharky/qt/sharkys-qtbase/blobs/8628259746664df7754f7b27d406d7bbd74580b0/src/network/kernel/qdnsreply.h#line154
Some notes about the implementation:
- the actual lookup code is run in a thread, managed by a global threadpool (QHostInfo-style)
- the thread and the QDnsReply both operate on a QSharedPointer<QDnsReplyPrivate>, so it doesn't matter whether the QDnsReply is deleted before or after the thread completes
Cheers,
Jeremy
More information about the Development
mailing list