-/* $Id: context.c,v 1.36 2000/01/28 20:17:42 brianp Exp $ */
+/* $Id: context.c,v 1.37 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "get.h"
#include "glapi.h"
#include "glapinoop.h"
+#include "glthread.h"
#include "hash.h"
#include "light.h"
#include "lines.h"
/**********************************************************************/
+_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
+
+
/*
* This function just calls all the various one-time-init functions in Mesa.
*/
static void one_time_init( void )
{
static GLboolean alreadyCalled = GL_FALSE;
+ _glthread_LOCK_MUTEX(OneTimeLock);
if (!alreadyCalled) {
/* do some implementation tests */
assert( sizeof(GLbyte) == 1 );
alreadyCalled = GL_TRUE;
}
+ _glthread_UNLOCK_MUTEX(OneTimeLock);
}
return GL_FALSE;
}
}
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount++;
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
init_attrib_groups( ctx );
gl_vb_free( ctx->VB );
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
- assert(ctx->Shared->RefCount>=0);
- if (ctx->Shared->RefCount==0) {
+ assert(ctx->Shared->RefCount >= 0);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ if (ctx->Shared->RefCount == 0) {
/* free shared state */
free_shared_state( ctx, ctx->Shared );
}
-/* $Id: hash.c,v 1.6 2000/01/24 16:19:54 brianp Exp $ */
+/* $Id: hash.c,v 1.7 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "all.h"
#else
#include "glheader.h"
+#include "glthread.h"
#include "hash.h"
#include "mem.h"
#endif
struct _mesa_HashTable {
struct HashEntry *Table[TABLE_SIZE];
GLuint MaxKey;
+ _glthread_Mutex Mutex;
};
assert(table);
assert(key);
+ _glthread_LOCK_MUTEX(table->Mutex);
+
if (key > table->MaxKey)
table->MaxKey = key;
if (entry->Key == key) {
/* replace entry's data */
entry->Data = data;
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return;
}
entry = entry->Next;
entry->Data = data;
entry->Next = table->Table[pos];
table->Table[pos] = entry;
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
}
assert(table);
assert(key);
+ _glthread_LOCK_MUTEX(table->Mutex);
+
pos = key & (TABLE_SIZE-1);
prev = NULL;
entry = table->Table[pos];
table->Table[pos] = entry->Next;
}
FREE(entry);
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return;
}
prev = entry;
entry = entry->Next;
}
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
}
-/* $Id: texobj.c,v 1.12 2000/01/24 20:53:32 brianp Exp $ */
+/* $Id: texobj.c,v 1.13 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* insert into linked list */
if (shared) {
+ _glthread_LOCK_MUTEX(shared->Mutex);
obj->Next = shared->TexObjectList;
shared->TexObjectList = obj;
+ _glthread_UNLOCK_MUTEX(shared->Mutex);
}
if (name > 0) {
/* unlink t from the linked list */
if (shared) {
+ _glthread_LOCK_MUTEX(shared->Mutex);
tprev = NULL;
tcurr = shared->TexObjectList;
while (tcurr) {
tprev = tcurr;
tcurr = tcurr->Next;
}
+ _glthread_UNLOCK_MUTEX(shared->Mutex);
}
if (t->Name) {