aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/basetypes/MCAutoreleasePool.h
blob: c3abf4779325cf9700a6fd902bdca060dbf9b56c (plain)
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
#ifndef MAILCORE_MCAUTORELEASEPOOL_H

#define MAILCORE_MCAUTORELEASEPOOL_H

#include <MailCore/MCObject.h>
#include <pthread.h>

#ifdef __cplusplus

typedef struct carray_s carray;

namespace mailcore {
    
    class MAILCORE_EXPORT AutoreleasePool : public Object {
    public:
        AutoreleasePool();
        virtual ~AutoreleasePool();
        
        static void autorelease(Object * obj);
        
    public: // subclass behavior
        virtual String * description();
        
    private:
        static void init();
        static pthread_key_t autoreleasePoolStackKey;
        carray * mPoolObjects;
        static carray * createAutoreleasePoolStackIfNeeded();
        static void destroyAutoreleasePoolStack(void *);
        static void initAutoreleasePoolStackKey();
        static AutoreleasePool * currentAutoreleasePool();
        virtual void add(Object * obj);
#ifdef __APPLE__
        void * mAppleAutoreleasePool;
        static void * createAppleAutoreleasePool();
        static void releaseAppleAutoreleasePool(void * appleAutoreleasePool);
#endif
    };

}

#endif

#endif