Revision: 54934
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54934&view=rev
Author:   brlcad
Date:     2013-03-28 05:32:36 +0000 (Thu, 28 Mar 2013)
Log Message:
-----------
provide an initial implementation of two functions to get/set the current cpu 
number in thread-local-storage (TLS).  this preliminarily uses boost threads, 
but will probably change to minimize the complexity where we have support for 
intrinsic compiler TLS.

Modified Paths:
--------------
    brlcad/trunk/src/libbu/parallel.h

Added Paths:
-----------
    brlcad/trunk/src/libbu/thread.cpp

Modified: brlcad/trunk/src/libbu/parallel.h
===================================================================
--- brlcad/trunk/src/libbu/parallel.h   2013-03-28 05:27:47 UTC (rev 54933)
+++ brlcad/trunk/src/libbu/parallel.h   2013-03-28 05:32:36 UTC (rev 54934)
@@ -32,6 +32,8 @@
  */
 extern int parallel_set_affinity(void);
 
+extern void thread_set_cpu(int cpu);
+extern int thread_get_cpu(void);
 
 
 /*

Added: brlcad/trunk/src/libbu/thread.cpp
===================================================================
--- brlcad/trunk/src/libbu/thread.cpp                           (rev 0)
+++ brlcad/trunk/src/libbu/thread.cpp   2013-03-28 05:32:36 UTC (rev 54934)
@@ -0,0 +1,53 @@
+/*                        T H R E A D . H
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+#include "common.h"
+
+#include <boost/thread/tss.hpp>
+
+static boost::thread_specific_ptr<int> thread_cpu;
+
+extern "C" {
+
+void
+thread_set_cpu(int cpu)
+{
+    thread_cpu.reset(new int(cpu));
+}
+
+
+int
+thread_get_cpu(void)
+{
+    return *thread_cpu.get();
+}
+
+
+} /* extern "C" */
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libbu/thread.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to