You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/11/21 10:01:13 UTC

svn commit: r882862 - /commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c

Author: mturk
Date: Sat Nov 21 09:01:12 2009
New Revision: 882862

URL: http://svn.apache.org/viewvc?rev=882862&view=rev
Log:
Use atomic increment for tlsd id

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=882862&r1=882861&r2=882862&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Sat Nov 21 09:01:12 2009
@@ -19,6 +19,7 @@
 #include "acr_arch.h"
 #include "acr_error.h"
 #include "acr_tlsd.h"
+#include "acr_atomics.h"
 #include "acr_vm.h"
 
 /**
@@ -35,7 +36,7 @@
 
 mode_t acr_default_umask;
 mode_t acr_default_perms;
-static volatile unsigned int acr_thread_id_cur = 0;
+static acr_atomic32_t acr_thread_id_cur = 0;
 static acr_thread_local_t _null_tlsd = { {NULL, NULL}, NULL, 0, 0 };
 static void acr_thread_key_destructor(void *data)
 {
@@ -119,9 +120,7 @@
             return &_null_tlsd;
         }
         else {
-            /* ###: The increment should be atomic operation
-             */
-            tlsd->id = ++acr_thread_id_cur;
+            tlsd->id = ACR_AtomicInc32(&acr_thread_id_cur);
             ACR_RING_INIT(&tlsd->data_ring, acr_tlsd_data_t, link);
             pthread_setspecific(acr_thread_key, tlsd);
             return tlsd;