Sha256: 7b456278945decf78604d51cd70295190afdd3b28ebe6a8e5462f3aa24111301

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

#ifndef SUNSCRAPERTHREAD_H
#define SUNSCRAPERTHREAD_H

#include <QObject>
#include <QSemaphore>
#include <QMap>

class QWebPage;
class QTimer;

class SunscraperThread : public QObject
{
    Q_OBJECT
public:
    static void invoke();
    static void commitSuicide();
    static SunscraperThread *instance();

signals:
    void finished(unsigned queryId, QString result);
    void timeout(unsigned queryId);

public slots:
    void loadHtml(unsigned queryId, QString html);
    void loadUrl(unsigned queryId, QString url);
    void setTimeout(unsigned queryId, unsigned timeout);
    void finalize(unsigned queryId);

private slots:
    void attachAPI();
    void routeTimeout();

private:
    static SunscraperThread *m_instance;
    static QSemaphore m_initializationLock;

#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
    static pthread_t m_thread;
#else
#error Your platform is unsupported. Implement SunscraperThread::invoke() and send a pull request.
#endif

    static void *thread_routine(void *arg);

    QMap<unsigned, QWebPage *> m_webPages;
    QMap<unsigned, QTimer *> m_timers;

    SunscraperThread();
    SunscraperThread(SunscraperThread &);

    QWebPage *initializeWebPage(unsigned queryId);
};

#endif // SUNSCRAPERTHREAD_H

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunscraper-1.1.0.beta2 ext/embed/sunscraperthread.h
sunscraper-1.1.0.beta1 ext/embed/sunscraperthread.h