root/trunk/src/IJob.h

Revision 167, 2.3 kB (checked in by jordi, 2 years ago)

Fixed a problem when typing too fast the text to find in the find bar that crashed the application.

Renamed the IJob::queue() function to IJob::enqueue().

Line 
1// ePDFView - A lightweight PDF Viewer.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#if !defined (__IJOB_H__)
19#define __IJOB_H__
20
21#if defined DEBUG
22#define JOB_NOTIFIER(callback, data) callback (data)
23#define JOB_DELETE TRUE
24#define JOB_NOTIFIER_END()
25#else // !DEBUG
26#define JOB_NOTIFIER(callback, data) g_idle_add (callback, data)
27#define JOB_DELETE FALSE
28#define JOB_NOTIFIER_END() delete job
29#endif // !DEBUG
30
31namespace ePDFView
32{
33    /// @class IJob
34    /// @brief Interface for jobs.
35    ///
36    /// A Job is simply a process that will be processed in background
37    /// by the dispatch() function.
38    ///
39    class IJob
40    {
41        public:
42            /// @brief Destroys all dynamically allocated memory for IJob.
43            virtual ~IJob (void) { }
44
45            static void clearQueue (void);
46            static gpointer dispatcher (gpointer data);
47            static void init (void);
48            static void enqueue (IJob *job);
49           
50            ///
51            /// @brief Runs the job.
52            ///
53            /// This is called by the dispatcher() function when
54            /// the job must start its work. It's the job's entry point.
55            ///
56            /// @return TRUE if the job must be deleted after the
57            ///         call to run(). FALSE if the job will be
58            ///         deleted by himself.
59            ///
60            virtual gboolean run (void) = 0;
61           
62        protected:
63            static GAsyncQueue *m_JobsQueue;
64
65            /// @brief Creates a new IJob object.
66            IJob () { }
67    };
68}
69
70#endif // __IJOB_H__
Note: See TracBrowser for help on using the browser.