Skip to content

Commit

Permalink
Fix python imath export (AcademySoftwareFoundation#207)
Browse files Browse the repository at this point in the history
Also removes thread library search, which is unused here.

Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd authored and cary-ilm committed Jan 17, 2022
1 parent c8222fb commit 7b3ae41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
15 changes: 0 additions & 15 deletions config/ImathSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,3 @@ if(IMATH_USE_CLANG_TIDY)
-checks=*;
)
endif()

#
# Dependent libraries
#

# So we know how to link / use threads and don't have to have a -pthread
# everywhere...
if(NOT TARGET Threads::Threads)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)
if(NOT Threads_FOUND)
message(FATAL_ERROR "Unable to find a threading library, required for PyImathTask")
endif()
endif()
2 changes: 2 additions & 0 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

project(PyImath VERSION 3.2.0 LANGUAGES C CXX)

#######################################
#######################################
# This declares all the configuration variables visible
Expand Down
25 changes: 15 additions & 10 deletions src/python/PyImath/PyImathTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace PyImath {

static WorkerPool *_currentPool = 0;
static WorkerPool *_currentPool = nullptr;

// Its not worth dispatching parallel tasks unless the iteration count
// is high enough. The time to create and launch parallel tasks takes
Expand All @@ -33,21 +33,26 @@ WorkerPool::setCurrentPool(WorkerPool *pool)
void
dispatchTask(Task &task,size_t length)
{
if (length > _minIterations &&
WorkerPool::currentPool() && !WorkerPool::currentPool()->inWorkerThread())
WorkerPool::currentPool()->dispatch(task,length);
else
task.execute(0,length,0);
if (length > _minIterations)
{
WorkerPool *curpool = WorkerPool::currentPool();
if (curpool && !curpool->inWorkerThread())
{
curpool->dispatch(task,length);
return;
}
}
task.execute(0,length,0);
}


size_t
workers()
{
if (WorkerPool::currentPool() && !WorkerPool::currentPool()->inWorkerThread())
return WorkerPool::currentPool()->workers();
else
return 1;
WorkerPool *curpool = WorkerPool::currentPool();
if (curpool && !curpool->inWorkerThread())
return curpool->workers();
return 1;
}

}

0 comments on commit 7b3ae41

Please sign in to comment.