HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TIL_ProxyManager.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TIL_ProxyManager.h (Tile Image Library, C++)
7  *
8  * COMMENTS:
9  * This class is a multithreaded proxy manager (disk cache manager).
10  */
11 
12 #ifndef TIL_PROXYMANAGER_H
13 #define TIL_PROXYMANAGER_H
14 
15 #include "TIL_API.h"
16 #include <UT/UT_LinkList.h>
17 #include <UT/UT_String.h>
18 #include "TIL_Defines.h"
19 
20 class UT_Thread;
21 class TIL_Tile;
22 class til_ProxyCommand;
23 class TIL_ProxyState;
24 
26 {
27 public:
28 
31 
32  // Proxy manager commands.
33  int readProxy (const char *cop_path, TIL_Tile *into_tile,
34  int xres, int yres);
35  void writeProxy(const char *cop_path, TIL_Tile *from_tile,
36  int xres, int yres);
37 
38  void clearCopProxies(const char *cop_path);
39  void clearAllProxies();
40 
41  void init();
42 
43  // Proxy Options.
44  void setProxyGeneration(int on);
45  void setProxyDir(const char *dir);
46  void setProxyLimit(int on);
47  void setProxyDiskLimit(int size);
48  void setProxyCrossPlatform(int enable);
49 
50  int getProxyGeneration() const;
51  int getProxyLimit() const;
52  int getProxyDiskLimit() const;
53  const char *getProxyDir() const;
54  int getProxyCrossPlatform() const;
55 
56 private:
57  void launchManagerProcess();
58  static void * threadProcess(void *data);
59 
60  // Separate thread functions:
61  void proxyManagerLoop();
62 
63  // command execution
64  int executeNextCommand();
65 
66  // if disk space limiting is on, gotta garbage collect...
67  void garbageCollect(int limit);
68 
69  // determine the state of all the proxies on disk, called once at startup
70  void determineProxyState(const char *proxy_dir);
71 
72  // the actual operations decoupled from the program calls.
73  void doWriteTile(const char *path, TIL_Tile *tile,
74  int xres, int yres);
75  void doClearCopProxies(const char *path);
76  void doClearAllProxies();
77 
78  // directory validation & creation... returns 0 if the path can't be
79  // created.
80  int ensurePathExists(const char *path);
81 
82  void addProxyState(TIL_ProxyState *);
83  TIL_ProxyState * usedProxyState(TIL_ProxyState *);
84  void removeProxyState(TIL_ProxyState *);
85 
86 private:
87  UT_LinkList myCommandList;
88 
89  // options
90  int myProxyEnable;
91  int myProxyLimit;
92  int myProxyDiskLimit;
93  UT_String myProxyUserDir;
94  UT_String myProxyDir;
95  int myProxyCrossPlatform;
96 
97  // proxy management stuff.
98  UT_String myProxyIndexFile;
99  UT_String myProxyDataFile;
100 
101  UT_LinkList *myProxyStateQueue;
102  TIL_ProxyState *myProxyStateTable[PROXY_TABLE_SIZE];
103  int myTotalProxySize;
104 
105  // multithread support
106  UT_Thread *myThread;
107  UT_Lock myCommandLock;
108  UT_Lock myCurrentPathLock;
109  UT_Lock myIndexFileLock;
110  UT_Lock myReadLock;
111  const char *myCurrentReadPath;
112  const char *myCurrentWritePath;
113 
114  TIL_ProxyManager *myThis;
115 };
116 
117 #endif
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
GLsizeiptr size
Definition: glcorearb.h:663
GLboolean * data
Definition: glcorearb.h:130
#define PROXY_TABLE_SIZE
Definition: TIL_Defines.h:158
#define TIL_API
Definition: TIL_API.h:10