MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / ContextHash

Class ContextHash

server/ContextHash.h:35–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace faker
34{
35 class ContextHash : public HASH
36 {
37 public:
38
39 static ContextHash *getInstance(void)
40 {
41 if(instance == NULL)
42 {
43 util::CriticalSection::SafeLock l(instanceMutex);
44 if(instance == NULL) instance = new ContextHash;
45 }
46 return instance;
47 }
48
49 static bool isAlloc(void) { return instance != NULL; }
50
51 void add(GLXContext ctx, VGLFBConfig config, Bool direct)
52 {
53 if(!ctx || !config) THROW("Invalid argument");
54 ContextAttribs *attribs = NULL;
55 attribs = new ContextAttribs;
56 attribs->config = config;
57 attribs->direct = direct;
58 HASH::add(ctx, NULL, attribs);
59 }
60
61 VGLFBConfig findConfig(GLXContext ctx)
62 {
63 if(!ctx) THROW("Invalid argument");
64 ContextAttribs *attribs = HASH::find(ctx, NULL);
65 if(attribs) return attribs->config;
66 return 0;
67 }
68
69 Bool isDirect(GLXContext ctx)
70 {
71 if(ctx)
72 {
73 ContextAttribs *attribs = HASH::find(ctx, NULL);
74 if(attribs) return attribs->direct;
75 }
76 return -1;
77 }
78
79 void remove(GLXContext ctx)
80 {
81 if(ctx) HASH::remove(ctx, NULL);
82 }
83
84 private:
85
86 ~ContextHash(void)
87 {
88 HASH::kill();
89 }
90
91 void detach(HashEntry *entry)
92 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected