+ecore_thread_max_{set,get} to return/set the max number of threads ecore will attemp...
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 21 Jul 2010 01:04:28 +0000 (01:04 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 21 Jul 2010 01:04:28 +0000 (01:04 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@50397 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/Ecore.h
src/lib/ecore/ecore_thread.c

index f23ed15..6419ac7 100644 (file)
@@ -353,6 +353,8 @@ extern "C" {
    EAPI int           ecore_thread_active_get(void);
    EAPI int           ecore_thread_pending_get(void);
    EAPI int           ecore_thread_pending_long_get(void);
+   EAPI int           ecore_thread_max_get(void);
+   EAPI void          ecore_thread_max_set(int num);
 
 
    EAPI double ecore_time_get(void);
index ee032ec..185023f 100644 (file)
@@ -326,6 +326,10 @@ _ecore_thread_shutdown(void)
    del_handler = NULL;
 #endif
 }
+/**
+ * @defgroup Ecore_Thread Ecore Thread Functions
+ * These functions allow for ecore-managed threads which integrate with ecore's main loop.
+       */
 
 /**
  * @brief Run some blocking code in a parrallel thread to avoid locking the main loop.
@@ -698,3 +702,32 @@ ecore_thread_pending_long_get(void)
    return 0;
 #endif
 }
+
+
+/**
+ * @brief Get the max number of threads that can run simultaneously
+ * @return Max number of threads ecore will run
+ * This returns the total number of threads that ecore will attempt to run
+ * simultaneously.
+ */
+EAPI int
+ecore_thread_max_get(void)
+{
+         return _ecore_thread_count_max;
+}
+
+/**
+ * @brief Set the max number of threads that can run simultaneously
+ * @param num The new maximum
+ * This sets the maximum number of threads that ecore will try to run
+ * simultaneously.  This number cannot be < 1 or >= 2x the number of active cpus.
+ */
+EAPI void
+ecore_thread_max_set(int num)
+{
+   if (num < 1) return;
+   /* avoid doing something hilarious by blocking dumb users */
+   if (num >= (2 * eina_cpu_count())) return;
+
+   _ecore_thread_count_max = num;
+}