File: AsyncSync.h

package info (click to toggle)
kwave 0.7.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,048 kB
  • ctags: 4,906
  • sloc: cpp: 31,275; ansic: 13,111; sh: 9,511; perl: 2,724; makefile: 786; asm: 145
file content (91 lines) | stat: -rw-r--r-- 2,492 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/***************************************************************************
			  AsyncSync.h  -  multithreading support for qt
			     -------------------
    begin                : Jun 1997
    copyright            : (C) 2000 by Brian Theodore,
                           Science Applications International Corp.
                           Simulation Technology Division
    email                : theodore@std.saic.com

  (copied to the kwave project by Thomas.Eschenbacher@gmx.de at Jun 2000)
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _ASYNC_SYNC_H_
#define _ASYNC_SYNC_H_

#include "config.h"
#include <qobject.h>
#include "mt/Mutex.h"

class QGList;
class QSocketNotifier;

class AsyncSync : public QObject
{
    Q_OBJECT

public :
    /**
     * Default Constructor
     */
    AsyncSync();

    /**
     * Default Destructor
     */
    virtual ~AsyncSync();

protected slots :

    /**
     * Slot called synchronously by the X server in response to the
     * asynchronous file descriptor it is watching having data ready.
     */
    void SyncHandler();

public slots :

    /**
     * Slot to be called by asynchronous client.  This slot does not more
     * than write to pipe, which will trigger the X server to respond
     * to the file descriptor, and synchronously call the SyncHandler
     */
    void AsyncHandler();

signals :

    /**
     * Signal emitted when the sync handler gets called
     */
    void Activated();

private :

    /**
     * IPC pipe for async/sync communication with X server
     */
    int m_fds[2];

    /**
     * Socket notifier to call slot when pipe has message to read
     */
    QSocketNotifier *m_sn;

    /**
     * Mutex for securing the creation/destruction, which seems
     * to be NOT threadsafe !!!???
     */
    static Mutex m_lock;

};

#endif // _ASYNC_SYNC_H_