blob: 2eed40844fe6f882e3d9b3ebbb7c200efdac3baf (
plain) (
blame)
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
|
#ifndef GIRMEM_HPP_INCLUDED
#define GIRMEM_HPP_INCLUDED
/* The following pthread crap mirrors what is in pthreadx.h, which is
what girmem.cpp uses to declare the lock interface. We can't simply
include pthreadx.h here, because it's an internal Xmlrpc-c header file,
and this is an external one.
This is a stopgap measure until we do something cleaner, such as expose
pthreadx.h as an external interface (class girlock, maybe?) or create
a lock class with virtual methods.
The problem we're solving is that class autoObject contains
a pthread_mutex_t member, and on Windows, there's no such type.
*/
#ifndef WIN32
# include <pthread.h>
typedef pthread_mutex_t girmem_lock;
#else
# include <windows.h>
typedef CRITICAL_SECTION girmem_lock;
#endif
namespace girmem {
class autoObjectPtr;
class autoObject {
friend class autoObjectPtr;
public:
void incref();
void decref(bool * const unreferencedP);
protected:
autoObject();
virtual ~autoObject();
private:
girmem_lock refcountLock;
unsigned int refcount;
};
class autoObjectPtr {
public:
autoObjectPtr();
autoObjectPtr(girmem::autoObject * objectP);
autoObjectPtr(girmem::autoObjectPtr const& autoObjectPtr);
~autoObjectPtr();
void
point(girmem::autoObject * const objectP);
void
unpoint();
autoObjectPtr
operator=(girmem::autoObjectPtr const& objectPtr);
girmem::autoObject *
operator->() const;
girmem::autoObject *
get() const;
protected:
girmem::autoObject * objectP;
};
} // namespace
#endif
|