File: TSS_Object.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 (70 lines) | stat: -rw-r--r-- 2,405 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
/***************************************************************************
    TSS_Object.h  - base class for usage of TSS (supports asynchronous exits)
			     -------------------
    begin                : Sun Oct 01 2000
    copyright            : (C) 2000 by Thomas Eschenbacher
    email                : Thomas.Eschenbacher@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 _TSS_OBJECT_H_
#define _TSS_OBJECT_H_

#include "config.h"
#include <pthread.h>

/**
 * @class TSS_Object
 *
 * TSS_Object base class for usage of TSS, supports asynchronous exits
 * and cleans up the derived object if the thread that created it
 * is closed or exits without (having a chance for) cleaning up.
 *
 * Provides registration and a cleanup handler for objects in
 * thread-specific-storage (TSS). It should be inherited by all classes that
 * are only valid within a certain thread. The cleanup handler ensures
 * that the object will be removed if its owning thread died. For this,
 * the derived object must call the constructor and should have a
 * <b>virtual</b> destructor.
 *
 * @author Thomas Eschenbacher <Thomas.Eschenbacher@gmx.de>
 * @date 2000-10-01
 *
 * @bug I disabled TSS because it led into too many problems.
 * @see bug with id "libc/2650" of glibc !
 */
class TSS_Object
{
public:
    /**
     * Constructor, creates the TSS key
     */
    TSS_Object();

    /**
     * Destructor, releases the TSS key
     */
    virtual ~TSS_Object();

private:
    /** thread specific key */
    pthread_key_t m_key;

    /** identifier of the thread that created the object */
    pthread_t m_thread;

    /** number of allocated instances */
    static unsigned int m_count;
};

#endif /* _TSS_OBJECT_H_ */

/* end of mt/TSS_Object.h */