Commit 52da087e by Marcus Winter

task_cpp: refactored namespace from mtapi to tasks

parent a97a72c1
...@@ -125,7 +125,7 @@ CheckPartestInstall(${BUILD_TESTS} partest_includepath partest_libpath) ...@@ -125,7 +125,7 @@ CheckPartestInstall(${BUILD_TESTS} partest_includepath partest_libpath)
add_subdirectory(base_c) add_subdirectory(base_c)
add_subdirectory(base_cpp) add_subdirectory(base_cpp)
add_subdirectory(mtapi_c) add_subdirectory(mtapi_c)
add_subdirectory(mtapi_cpp) add_subdirectory(tasks_cpp)
add_subdirectory(mtapi_cpp_ext) add_subdirectory(mtapi_cpp_ext)
add_subdirectory(containers_cpp) add_subdirectory(containers_cpp)
add_subdirectory(algorithms_cpp) add_subdirectory(algorithms_cpp)
......
project (project_mtapi_cpp) project (project_tasks_cpp)
file(GLOB_RECURSE EMBB_MTAPI_CPP_SOURCES "src/*.cc" "src/*.h") file(GLOB_RECURSE EMBB_TASKS_CPP_SOURCES "src/*.cc" "src/*.h")
file(GLOB_RECURSE EMBB_MTAPI_CPP_HEADERS "include/*.h") file(GLOB_RECURSE EMBB_TASKS_CPP_HEADERS "include/*.h")
file(GLOB_RECURSE EMBB_MTAPI_CPP_TEST_SOURCES "test/*.cc" "test/*.h") file(GLOB_RECURSE EMBB_TASKS_CPP_TEST_SOURCES "test/*.cc" "test/*.h")
if (USE_AUTOMATIC_INITIALIZATION STREQUAL ON) if (USE_AUTOMATIC_INITIALIZATION STREQUAL ON)
message("-- Automatic initialization enabled (default)") message("-- Automatic initialization enabled (default)")
set(MTAPI_CPP_AUTOMATIC_INITIALIZE 1) set(TASKS_CPP_AUTOMATIC_INITIALIZE 1)
else() else()
set(MTAPI_CPP_AUTOMATIC_INITIALIZE 0) set(TASKS_CPP_AUTOMATIC_INITIALIZE 0)
message("-- Automatic initialization disabled") message("-- Automatic initialization disabled")
endif() endif()
message(" (set with command line option -DUSE_AUTOMATIC_INITIALIZATION=ON/OFF)") message(" (set with command line option -DUSE_AUTOMATIC_INITIALIZATION=ON/OFF)")
configure_file("include/embb/mtapi/internal/cmake_config.h.in" configure_file("include/embb/tasks/internal/cmake_config.h.in"
"include/embb/mtapi/internal/cmake_config.h") "include/embb/tasks/internal/cmake_config.h")
# Execute the GroupSources macro # Execute the GroupSources macro
include(${CMAKE_SOURCE_DIR}/CMakeCommon/GroupSourcesMSVC.cmake) include(${CMAKE_SOURCE_DIR}/CMakeCommon/GroupSourcesMSVC.cmake)
...@@ -22,8 +22,8 @@ GroupSourcesMSVC(include) ...@@ -22,8 +22,8 @@ GroupSourcesMSVC(include)
GroupSourcesMSVC(src) GroupSourcesMSVC(src)
GroupSourcesMSVC(test) GroupSourcesMSVC(test)
set (EMBB_MTAPI_CPP_INCLUDE_DIRS "include" "src" "test") set (EMBB_TASKS_CPP_INCLUDE_DIRS "include" "src" "test")
include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS} include_directories(${EMBB_TASKS_CPP_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../base_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../base_c/include
${CMAKE_CURRENT_BINARY_DIR}/../base_c/include ${CMAKE_CURRENT_BINARY_DIR}/../base_c/include
...@@ -31,19 +31,19 @@ include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS} ...@@ -31,19 +31,19 @@ include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include ${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include
${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include) ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include)
add_library (embb_mtapi_cpp ${EMBB_MTAPI_CPP_SOURCES} ${EMBB_MTAPI_CPP_HEADERS}) add_library (embb_tasks_cpp ${EMBB_TASKS_CPP_SOURCES} ${EMBB_TASKS_CPP_HEADERS})
target_link_libraries(embb_mtapi_cpp embb_mtapi_c) target_link_libraries(embb_tasks_cpp embb_mtapi_c)
if (BUILD_TESTS STREQUAL ON) if (BUILD_TESTS STREQUAL ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include)
add_executable (embb_mtapi_cpp_test ${EMBB_MTAPI_CPP_TEST_SOURCES}) add_executable (embb_tasks_cpp_test ${EMBB_TASKS_CPP_TEST_SOURCES})
target_link_libraries(embb_mtapi_cpp_test embb_mtapi_cpp embb_mtapi_c partest target_link_libraries(embb_tasks_cpp_test embb_tasks_cpp embb_mtapi_c partest
embb_base_cpp embb_base_c ${compiler_libs}) embb_base_cpp embb_base_c ${compiler_libs})
CopyBin(BIN embb_mtapi_cpp_test DEST ${local_install_dir}) CopyBin(BIN embb_tasks_cpp_test DEST ${local_install_dir})
endif() endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include FILES_MATCHING PATTERN "*.h") DESTINATION include FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION include FILES_MATCHING PATTERN "*.h") DESTINATION include FILES_MATCHING PATTERN "*.h")
install(TARGETS embb_mtapi_cpp DESTINATION lib) install(TARGETS embb_tasks_cpp DESTINATION lib)
...@@ -24,15 +24,15 @@ ...@@ -24,15 +24,15 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_ACTION_H_ #ifndef EMBB_TASKS_ACTION_H_
#define EMBB_MTAPI_ACTION_H_ #define EMBB_TASKS_ACTION_H_
#include <embb/base/function.h> #include <embb/base/function.h>
#include <embb/mtapi/taskcontext.h> #include <embb/tasks/task_context.h>
#include <embb/mtapi/execution_policy.h> #include <embb/tasks/execution_policy.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
/** /**
* A function to be spawned as a Task. * A function to be spawned as a Task.
...@@ -103,7 +103,7 @@ class Action { ...@@ -103,7 +103,7 @@ class Action {
ExecutionPolicy execution_policy_; ExecutionPolicy execution_policy_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_ACTION_H_ #endif // EMBB_TASKS_ACTION_H_
...@@ -24,21 +24,21 @@ ...@@ -24,21 +24,21 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_CONTINUATION_H_ #ifndef EMBB_TASKS_CONTINUATION_H_
#define EMBB_MTAPI_CONTINUATION_H_ #define EMBB_TASKS_CONTINUATION_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/taskcontext.h> #include <embb/tasks/task_context.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
#include <embb/mtapi/task.h> #include <embb/tasks/task.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
/** /**
* Helper struct for Continuation. * Helper struct for Continuation.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
struct ContinuationStage; struct ContinuationStage;
...@@ -46,19 +46,19 @@ struct ContinuationStage; ...@@ -46,19 +46,19 @@ struct ContinuationStage;
* A Continuation encapsulates a chain of \link Action Actions \endlink to be * A Continuation encapsulates a chain of \link Action Actions \endlink to be
* executed consecutively. * executed consecutively.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class Continuation { class Continuation {
public: public:
/** /**
* Copy constructor. * Copies a Continuation.
*/ */
Continuation( Continuation(
Continuation const & cont /**< [in] The Continuation to copy. */ Continuation const & cont /**< [in] The Continuation to copy. */
); );
/** /**
* Destructor. * Destroys a Continuation.
*/ */
~Continuation(); ~Continuation();
...@@ -99,7 +99,7 @@ class Continuation { ...@@ -99,7 +99,7 @@ class Continuation {
ContinuationStage * last_; ContinuationStage * last_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_CONTINUATION_H_ #endif // EMBB_TASKS_CONTINUATION_H_
...@@ -24,13 +24,14 @@ ...@@ -24,13 +24,14 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_EXECUTION_POLICY_H_ #ifndef EMBB_TASKS_EXECUTION_POLICY_H_
#define EMBB_MTAPI_EXECUTION_POLICY_H_ #define EMBB_TASKS_EXECUTION_POLICY_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
/** /**
* Describes the execution policy of a parallel algorithm. * Describes the execution policy of a parallel algorithm.
* The execution policy comprises * The execution policy comprises
...@@ -41,7 +42,7 @@ namespace mtapi { ...@@ -41,7 +42,7 @@ namespace mtapi {
* max_priorities - 1 as given during initialization using Node::Initialize(). * max_priorities - 1 as given during initialization using Node::Initialize().
* The default value of max_priorities is 4. * The default value of max_priorities is 4.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class ExecutionPolicy{ class ExecutionPolicy{
public: public:
...@@ -145,7 +146,8 @@ class ExecutionPolicy{ ...@@ -145,7 +146,8 @@ class ExecutionPolicy{
*/ */
mtapi_uint_t priority_; mtapi_uint_t priority_;
}; };
} // namespace mtapi
} // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_EXECUTION_POLICY_H_ #endif // EMBB_TASKS_EXECUTION_POLICY_H_
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_GROUP_H_ #ifndef EMBB_TASKS_GROUP_H_
#define EMBB_MTAPI_GROUP_H_ #define EMBB_TASKS_GROUP_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
#include <embb/mtapi/task.h> #include <embb/tasks/task.h>
namespace embb { namespace embb {
...@@ -39,13 +39,13 @@ class Allocation; ...@@ -39,13 +39,13 @@ class Allocation;
} // namespace base } // namespace base
namespace mtapi { namespace tasks {
/** /**
* Represents a facility to wait for multiple related * Represents a facility to wait for multiple related
* \link Task Tasks\endlink. * \link Task Tasks\endlink.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class Group { class Group {
public: public:
...@@ -119,7 +119,7 @@ class Group { ...@@ -119,7 +119,7 @@ class Group {
mtapi_group_hndl_t handle_; mtapi_group_hndl_t handle_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_GROUP_H_ #endif // EMBB_TASKS_GROUP_H_
...@@ -24,18 +24,18 @@ ...@@ -24,18 +24,18 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_ #ifndef EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
#define EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_ #define EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
/* This file is used as input for CMake. CMake creates a file cmake_config.h in /* This file is used as input for CMake. CMake creates a file cmake_config.h in
its current build directory under the path builddir/embb/mtapi/internal/. From its current build directory under the path builddir/embb/tasks/internal/. From
there, the cmake_config.h can be included as usual using there, the cmake_config.h can be included as usual using
#include <embb/mtapi/internal/cmake_config.h> #include <embb/tasks/internal/cmake_config.h>
*/ */
/** /**
* Is used to enable automatic initialization of the MTAPI node * Is used to enable automatic initialization of the MTAPI node
*/ */
#define MTAPI_CPP_AUTOMATIC_INITIALIZE ${MTAPI_CPP_AUTOMATIC_INITIALIZE} #define TASKS_CPP_AUTOMATIC_INITIALIZE ${TASKS_CPP_AUTOMATIC_INITIALIZE}
#endif // EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_ #endif // EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
...@@ -24,17 +24,17 @@ ...@@ -24,17 +24,17 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_NODE_H_ #ifndef EMBB_TASKS_NODE_H_
#define EMBB_MTAPI_NODE_H_ #define EMBB_TASKS_NODE_H_
#include <list> #include <list>
#include <embb/base/core_set.h> #include <embb/base/core_set.h>
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
#include <embb/mtapi/task.h> #include <embb/tasks/task.h>
#include <embb/mtapi/continuation.h> #include <embb/tasks/continuation.h>
#include <embb/mtapi/group.h> #include <embb/tasks/group.h>
#include <embb/mtapi/queue.h> #include <embb/tasks/queue.h>
namespace embb { namespace embb {
...@@ -44,12 +44,12 @@ class Allocation; ...@@ -44,12 +44,12 @@ class Allocation;
} // namespace base } // namespace base
namespace mtapi { namespace tasks {
/** /**
* A singleton representing the MTAPI runtime. * A singleton representing the MTAPI runtime.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class Node { class Node {
public: public:
...@@ -225,7 +225,7 @@ class Node { ...@@ -225,7 +225,7 @@ class Node {
std::list<Group*> groups_; std::list<Group*> groups_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_NODE_H_ #endif // EMBB_TASKS_NODE_H_
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_QUEUE_H_ #ifndef EMBB_TASKS_QUEUE_H_
#define EMBB_MTAPI_QUEUE_H_ #define EMBB_TASKS_QUEUE_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
#include <embb/mtapi/task.h> #include <embb/tasks/task.h>
#include <embb/mtapi/group.h> #include <embb/tasks/group.h>
namespace embb { namespace embb {
...@@ -40,12 +40,12 @@ class Allocation; ...@@ -40,12 +40,12 @@ class Allocation;
} // namespace base } // namespace base
namespace mtapi { namespace tasks {
/** /**
* Allows for stream processing, either ordered or unordered. * Allows for stream processing, either ordered or unordered.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class Queue { class Queue {
public: public:
...@@ -110,7 +110,7 @@ class Queue { ...@@ -110,7 +110,7 @@ class Queue {
mtapi_queue_hndl_t handle_; mtapi_queue_hndl_t handle_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_QUEUE_H_ #endif // EMBB_TASKS_QUEUE_H_
...@@ -24,19 +24,19 @@ ...@@ -24,19 +24,19 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_TASK_H_ #ifndef EMBB_TASKS_TASK_H_
#define EMBB_MTAPI_TASK_H_ #define EMBB_TASKS_TASK_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
/** /**
* A Task represents a running Action. * A Task represents a running Action.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class Task { class Task {
public: public:
...@@ -109,7 +109,7 @@ class Task { ...@@ -109,7 +109,7 @@ class Task {
mtapi_task_hndl_t handle_; mtapi_task_hndl_t handle_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_TASK_H_ #endif // EMBB_TASKS_TASK_H_
...@@ -24,18 +24,18 @@ ...@@ -24,18 +24,18 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_TASKCONTEXT_H_ #ifndef EMBB_TASKS_TASK_CONTEXT_H_
#define EMBB_MTAPI_TASKCONTEXT_H_ #define EMBB_TASKS_TASK_CONTEXT_H_
#include <embb/mtapi/c/mtapi.h> #include <embb/mtapi/c/mtapi.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
/** /**
* Provides information about the status of the currently running Task. * Provides information about the status of the currently running Task.
* *
* \ingroup CPP_MTAPI * \ingroup CPP_TASKS
*/ */
class TaskContext { class TaskContext {
public: public:
...@@ -72,7 +72,7 @@ class TaskContext { ...@@ -72,7 +72,7 @@ class TaskContext {
mtapi_task_context_t * context_; mtapi_task_context_t * context_;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // EMBB_MTAPI_TASKCONTEXT_H_ #endif // EMBB_TASKS_TASK_CONTEXT_H_
...@@ -24,32 +24,30 @@ ...@@ -24,32 +24,30 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef EMBB_MTAPI_MTAPI_H_ #ifndef EMBB_TASKS_TASKS_H_
#define EMBB_MTAPI_MTAPI_H_ #define EMBB_TASKS_TASKS_H_
/** /**
* \defgroup CPP_MTAPI MTAPI * \defgroup CPP_TASKS Tasks
* C++ wrapper around C implementation of MTAPI. * Simple task management based on MTAPI.
* For a description of the basic concepts, see the
* \ref C_MTAPI "C implementation of MTAPI".
* \ingroup CPP * \ingroup CPP
*/ */
#include <embb/mtapi/internal/cmake_config.h> #include <embb/tasks/internal/cmake_config.h>
#define MTAPI_CPP_TASK_JOB 1 #define TASKS_CPP_JOB 1
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if TASKS_CPP_AUTOMATIC_INITIALIZE
#define MTAPI_CPP_AUTOMATIC_DOMAIN_ID 1 #define TASKS_CPP_AUTOMATIC_DOMAIN_ID 1
#define MTAPI_CPP_AUTOMATIC_NODE_ID 1 #define TASKS_CPP_AUTOMATIC_NODE_ID 1
#endif #endif
#include <embb/mtapi/execution_policy.h> #include <embb/tasks/execution_policy.h>
#include <embb/mtapi/action.h> #include <embb/tasks/action.h>
#include <embb/mtapi/continuation.h> #include <embb/tasks/continuation.h>
#include <embb/mtapi/group.h> #include <embb/tasks/group.h>
#include <embb/mtapi/node.h> #include <embb/tasks/node.h>
#include <embb/mtapi/queue.h> #include <embb/tasks/queue.h>
#include <embb/mtapi/task.h> #include <embb/tasks/task.h>
#include <embb/mtapi/taskcontext.h> #include <embb/tasks/task_context.h>
#endif // EMBB_MTAPI_MTAPI_H_ #endif // EMBB_TASKS_TASKS_H_
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
#include <embb/base/memory_allocation.h> #include <embb/base/memory_allocation.h>
#include <embb/base/function.h> #include <embb/base/function.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
#include <continuationstage.h> #include <continuationstage.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
Continuation::Continuation(Action action) { Continuation::Continuation(Action action) {
first_ = last_ = embb::base::Allocation::New<ContinuationStage>(); first_ = last_ = embb::base::Allocation::New<ContinuationStage>();
...@@ -50,10 +50,10 @@ Continuation::~Continuation() { ...@@ -50,10 +50,10 @@ Continuation::~Continuation() {
} }
void Continuation::ExecuteContinuation(TaskContext &) { void Continuation::ExecuteContinuation(TaskContext &) {
mtapi::ContinuationStage * stage = first_; ContinuationStage * stage = first_;
mtapi::Node & node = mtapi::Node::GetInstance(); Node & node = Node::GetInstance();
while (NULL != stage) { while (NULL != stage) {
mtapi::Task task = node.Spawn(stage->action); Task task = node.Spawn(stage->action);
task.Wait(MTAPI_INFINITE); task.Wait(MTAPI_INFINITE);
stage = stage->next; stage = stage->next;
} }
...@@ -61,7 +61,7 @@ void Continuation::ExecuteContinuation(TaskContext &) { ...@@ -61,7 +61,7 @@ void Continuation::ExecuteContinuation(TaskContext &) {
// delete stages // delete stages
stage = first_; stage = first_;
while (NULL != stage) { while (NULL != stage) {
mtapi::ContinuationStage * next = stage->next; ContinuationStage * next = stage->next;
embb::base::Allocation::Delete(stage); embb::base::Allocation::Delete(stage);
stage = next; stage = next;
} }
...@@ -90,5 +90,5 @@ Task Continuation::Spawn(ExecutionPolicy execution_policy) { ...@@ -90,5 +90,5 @@ Task Continuation::Spawn(ExecutionPolicy execution_policy) {
ExecutionPolicy(execution_policy))); ExecutionPolicy(execution_policy)));
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -24,20 +24,20 @@ ...@@ -24,20 +24,20 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_ #ifndef TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
#define MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_ #define TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
struct ContinuationStage { struct ContinuationStage {
mtapi::Action action; Action action;
ContinuationStage * next; ContinuationStage * next;
}; };
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
#endif // MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_ #endif // TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <embb/mtapi/execution_policy.h> #include <embb/tasks/execution_policy.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
#include <embb/base/exceptions.h> #include <embb/base/exceptions.h>
#include <embb/base/c/internal/bitset.h> #include <embb/base/c/internal/bitset.h>
#include <cassert> #include <cassert>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
ExecutionPolicy::ExecutionPolicy() : ExecutionPolicy::ExecutionPolicy() :
priority_(DefaultPriority) { priority_(DefaultPriority) {
...@@ -120,5 +120,5 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const { ...@@ -120,5 +120,5 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const {
const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0; const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0;
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#include <cassert> #include <cassert>
#include <embb/base/exceptions.h> #include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
Group::Group() { Group::Group() {
Create(); Create();
...@@ -92,5 +92,5 @@ mtapi_status_t Group::WaitAll(mtapi_timeout_t timeout) { ...@@ -92,5 +92,5 @@ mtapi_status_t Group::WaitAll(mtapi_timeout_t timeout) {
return status; return status;
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -31,22 +31,22 @@ ...@@ -31,22 +31,22 @@
#include <embb/base/memory_allocation.h> #include <embb/base/memory_allocation.h>
#include <embb/base/exceptions.h> #include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if TASKS_CPP_AUTOMATIC_INITIALIZE
#include <embb/base/mutex.h> #include <embb/base/mutex.h>
#endif #endif
namespace { namespace {
static embb::mtapi::Node * node_instance = NULL; static embb::tasks::Node * node_instance = NULL;
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if TASKS_CPP_AUTOMATIC_INITIALIZE
static embb::base::Mutex init_mutex; static embb::base::Mutex init_mutex;
#endif #endif
} }
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
void Node::action_func( void Node::action_func(
const void* args, const void* args,
...@@ -56,9 +56,9 @@ void Node::action_func( ...@@ -56,9 +56,9 @@ void Node::action_func(
const void* /*node_local_data*/, const void* /*node_local_data*/,
mtapi_size_t /*node_local_data_size*/, mtapi_size_t /*node_local_data_size*/,
mtapi_task_context_t * context) { mtapi_task_context_t * context) {
mtapi::Action * action = Action * action =
reinterpret_cast<mtapi::Action*>(const_cast<void*>(args)); reinterpret_cast<Action*>(const_cast<void*>(args));
mtapi::TaskContext task_context(context); TaskContext task_context(context);
(*action)(task_context); (*action)(task_context);
embb::base::Allocation::Delete(action); embb::base::Allocation::Delete(action);
} }
...@@ -76,7 +76,7 @@ Node::Node( ...@@ -76,7 +76,7 @@ Node::Node(
} }
core_count_ = info.hardware_concurrency; core_count_ = info.hardware_concurrency;
worker_thread_count_ = embb_core_set_count(&attr->core_affinity); worker_thread_count_ = embb_core_set_count(&attr->core_affinity);
action_handle_ = mtapi_action_create(MTAPI_CPP_TASK_JOB, action_func, action_handle_ = mtapi_action_create(TASKS_CPP_JOB, action_func,
MTAPI_NULL, 0, MTAPI_NULL, &status); MTAPI_NULL, 0, MTAPI_NULL, &status);
if (MTAPI_SUCCESS != status) { if (MTAPI_SUCCESS != status) {
EMBB_THROW(embb::base::ErrorException, EMBB_THROW(embb::base::ErrorException,
...@@ -201,12 +201,12 @@ bool Node::IsInitialized() { ...@@ -201,12 +201,12 @@ bool Node::IsInitialized() {
} }
Node & Node::GetInstance() { Node & Node::GetInstance() {
#if MTAPI_CPP_AUTOMATIC_INITIALIZE #if TASKS_CPP_AUTOMATIC_INITIALIZE
if (!IsInitialized()) { if (!IsInitialized()) {
init_mutex.Lock(); init_mutex.Lock();
if (!IsInitialized()) { if (!IsInitialized()) {
Node::Initialize( Node::Initialize(
MTAPI_CPP_AUTOMATIC_DOMAIN_ID, MTAPI_CPP_AUTOMATIC_NODE_ID); TASKS_CPP_AUTOMATIC_DOMAIN_ID, TASKS_CPP_AUTOMATIC_NODE_ID);
atexit(Node::Finalize); atexit(Node::Finalize);
} }
init_mutex.Unlock(); init_mutex.Unlock();
...@@ -217,7 +217,7 @@ Node & Node::GetInstance() { ...@@ -217,7 +217,7 @@ Node & Node::GetInstance() {
return *node_instance; return *node_instance;
} else { } else {
EMBB_THROW(embb::base::ErrorException, EMBB_THROW(embb::base::ErrorException,
"mtapi::Node is not initialized"); "embb::tasks::Node is not initialized");
} }
#endif #endif
} }
...@@ -228,7 +228,7 @@ void Node::Finalize() { ...@@ -228,7 +228,7 @@ void Node::Finalize() {
node_instance = NULL; node_instance = NULL;
} else { } else {
EMBB_THROW(embb::base::ErrorException, EMBB_THROW(embb::base::ErrorException,
"mtapi::Node is not initialized"); "embb::tasks::Node is not initialized");
} }
} }
...@@ -270,5 +270,5 @@ Continuation Node::First(Action action) { ...@@ -270,5 +270,5 @@ Continuation Node::First(Action action) {
return Continuation(action); return Continuation(action);
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#include <cassert> #include <cassert>
#include <embb/base/exceptions.h> #include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
Queue::Queue(mtapi_uint_t priority, bool ordered) { Queue::Queue(mtapi_uint_t priority, bool ordered) {
mtapi_status_t status; mtapi_status_t status;
...@@ -51,7 +51,7 @@ Queue::Queue(mtapi_uint_t priority, bool ordered) { ...@@ -51,7 +51,7 @@ Queue::Queue(mtapi_uint_t priority, bool ordered) {
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status); mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
handle_ = mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job, &attr, &status); handle_ = mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job, &attr, &status);
if (MTAPI_SUCCESS != status) { if (MTAPI_SUCCESS != status) {
...@@ -86,5 +86,5 @@ Task Queue::Spawn(Group const * group, Action action) { ...@@ -86,5 +86,5 @@ Task Queue::Spawn(Group const * group, Action action) {
return Task(action, handle_, group->handle_); return Task(action, handle_, group->handle_);
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
#include <embb/base/memory_allocation.h> #include <embb/base/memory_allocation.h>
#include <embb/base/exceptions.h> #include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
Task::Task() { Task::Task() {
handle_.id = 0; handle_.id = 0;
...@@ -59,7 +59,7 @@ Task::Task( ...@@ -59,7 +59,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status); mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action); Action* holder = embb::base::Allocation::New<Action>(action);
handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job, handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job,
...@@ -86,7 +86,7 @@ Task::Task( ...@@ -86,7 +86,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status); mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action); Action* holder = embb::base::Allocation::New<Action>(action);
handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job, handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job,
...@@ -114,7 +114,7 @@ Task::Task( ...@@ -114,7 +114,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status); mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action); Action* holder = embb::base::Allocation::New<Action>(action);
void * idptr = MTAPI_NULL; void * idptr = MTAPI_NULL;
...@@ -216,5 +216,5 @@ void Task::Cancel() { ...@@ -216,5 +216,5 @@ void Task::Cancel() {
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include <cassert> #include <cassert>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
namespace embb { namespace embb {
namespace mtapi { namespace tasks {
TaskContext::TaskContext(mtapi_task_context_t * task_context) TaskContext::TaskContext(mtapi_task_context_t * task_context)
: context_(task_context) { : context_(task_context) {
...@@ -57,5 +57,5 @@ void TaskContext::SetStatus(mtapi_status_t error_code) { ...@@ -57,5 +57,5 @@ void TaskContext::SetStatus(mtapi_status_t error_code) {
assert(MTAPI_SUCCESS == status); assert(MTAPI_SUCCESS == status);
} }
} // namespace mtapi } // namespace tasks
} // namespace embb } // namespace embb
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
#include <iostream> #include <iostream>
#include <mtapi_cpp_test_task.h> #include <tasks_cpp_test_task.h>
#include <mtapi_cpp_test_group.h> #include <tasks_cpp_test_group.h>
#include <mtapi_cpp_test_queue.h> #include <tasks_cpp_test_queue.h>
PT_MAIN("MTAPI C++") { PT_MAIN("TASKS") {
PT_RUN(TaskTest); PT_RUN(TaskTest);
PT_RUN(GroupTest); PT_RUN(GroupTest);
PT_RUN(QueueTest); PT_RUN(QueueTest);
......
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_ #ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_ #define TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
#include <partest/partest.h> #include <partest/partest.h>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
#define THIS_DOMAIN_ID 1 #define THIS_DOMAIN_ID 1
#define THIS_NODE_ID 1 #define THIS_NODE_ID 1
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_ #endif // TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include <iostream> #include <iostream>
#include <mtapi_cpp_test_config.h> #include <tasks_cpp_test_config.h>
#include <mtapi_cpp_test_group.h> #include <tasks_cpp_test_group.h>
#include <embb/base/c/memory_allocation.h> #include <embb/base/c/memory_allocation.h>
...@@ -38,7 +38,7 @@ struct result_example_struct { ...@@ -38,7 +38,7 @@ struct result_example_struct {
typedef struct result_example_struct result_example_t; typedef struct result_example_struct result_example_t;
static void testGroupAction(embb::mtapi::TaskContext & /*context*/) { static void testGroupAction(embb::tasks::TaskContext & /*context*/) {
//std::cout << "testGroupAction on core " << //std::cout << "testGroupAction on core " <<
// context.GetCurrentCoreNumber() << std::endl; // context.GetCurrentCoreNumber() << std::endl;
} }
...@@ -47,17 +47,17 @@ static void testDoSomethingElse() { ...@@ -47,17 +47,17 @@ static void testDoSomethingElse() {
} }
GroupTest::GroupTest() { GroupTest::GroupTest() {
CreateUnit("mtapi group test").Add(&GroupTest::TestBasic, this); CreateUnit("tasks_cpp group test").Add(&GroupTest::TestBasic, this);
} }
void GroupTest::TestBasic() { void GroupTest::TestBasic() {
//std::cout << "running testGroup..." << std::endl; //std::cout << "running testGroup..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID); embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::mtapi::Group & group = node.CreateGroup(); embb::tasks::Group & group = node.CreateGroup();
embb::mtapi::Task task; embb::tasks::Task task;
//std::cout << "wait all..." << std::endl; //std::cout << "wait all..." << std::endl;
...@@ -81,8 +81,8 @@ void GroupTest::TestBasic() { ...@@ -81,8 +81,8 @@ void GroupTest::TestBasic() {
node.DestroyGroup(group); node.DestroyGroup(group);
embb::mtapi::Node::Finalize(); embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0); PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u);
//std::cout << "...done" << std::endl << std::endl; //std::cout << "...done" << std::endl << std::endl;
} }
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_ #ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_ #define TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
#include <partest/partest.h> #include <partest/partest.h>
...@@ -37,4 +37,4 @@ class GroupTest : public partest::TestCase { ...@@ -37,4 +37,4 @@ class GroupTest : public partest::TestCase {
void TestBasic(); void TestBasic();
}; };
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_ #endif // TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include <cstdlib> #include <cstdlib>
#include <mtapi_cpp_test_config.h> #include <tasks_cpp_test_config.h>
#include <mtapi_cpp_test_queue.h> #include <tasks_cpp_test_queue.h>
#include <embb/base/c/memory_allocation.h> #include <embb/base/c/memory_allocation.h>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define TASK_TEST_ID 23 #define TASK_TEST_ID 23
#define QUEUE_TEST_ID 17 #define QUEUE_TEST_ID 17
static void testQueueAction(embb::mtapi::TaskContext & /*context*/) { static void testQueueAction(embb::tasks::TaskContext & /*context*/) {
//std::cout << "testQueueAction on core " << //std::cout << "testQueueAction on core " <<
// context.GetCurrentCoreNumber() << std::endl; // context.GetCurrentCoreNumber() << std::endl;
} }
...@@ -44,18 +44,18 @@ static void testDoSomethingElse() { ...@@ -44,18 +44,18 @@ static void testDoSomethingElse() {
} }
QueueTest::QueueTest() { QueueTest::QueueTest() {
CreateUnit("mtapi queue test").Add(&QueueTest::TestBasic, this); CreateUnit("tasks_cpp queue test").Add(&QueueTest::TestBasic, this);
} }
void QueueTest::TestBasic() { void QueueTest::TestBasic() {
//std::cout << "running testQueue..." << std::endl; //std::cout << "running testQueue..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID); embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::mtapi::Queue & queue = node.CreateQueue(0, false); embb::tasks::Queue & queue = node.CreateQueue(0, false);
embb::mtapi::Task task = queue.Spawn(testQueueAction); embb::tasks::Task task = queue.Spawn(testQueueAction);
testDoSomethingElse(); testDoSomethingElse();
...@@ -63,8 +63,8 @@ void QueueTest::TestBasic() { ...@@ -63,8 +63,8 @@ void QueueTest::TestBasic() {
node.DestroyQueue(queue); node.DestroyQueue(queue);
embb::mtapi::Node::Finalize(); embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0); PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u);
//std::cout << "...done" << std::endl << std::endl; //std::cout << "...done" << std::endl << std::endl;
} }
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_ #ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_ #define TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
#include <partest/partest.h> #include <partest/partest.h>
...@@ -37,4 +37,4 @@ class QueueTest : public partest::TestCase { ...@@ -37,4 +37,4 @@ class QueueTest : public partest::TestCase {
void TestBasic(); void TestBasic();
}; };
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_ #endif // TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <mtapi_cpp_test_config.h> #include <tasks_cpp_test_config.h>
#include <mtapi_cpp_test_task.h> #include <tasks_cpp_test_task.h>
#include <embb/base/c/memory_allocation.h> #include <embb/base/c/memory_allocation.h>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
static void testTaskAction( static void testTaskAction(
char const * msg, char const * msg,
std::string * output, std::string * output,
embb::mtapi::TaskContext & /*context*/) { embb::tasks::TaskContext & /*context*/) {
//std::cout << "testTaskAction " << msg << " on core " << //std::cout << "testTaskAction " << msg << " on core " <<
// context.GetCurrentCoreNumber() << std::endl; // context.GetCurrentCoreNumber() << std::endl;
*output = msg; *output = msg;
...@@ -47,11 +47,11 @@ static void testTaskAction( ...@@ -47,11 +47,11 @@ static void testTaskAction(
static void testRecursiveTaskAction( static void testRecursiveTaskAction(
int * value, int * value,
embb::mtapi::TaskContext & /*context*/) { embb::tasks::TaskContext & /*context*/) {
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
*value = *value + 1; *value = *value + 1;
if (*value < 1000) { if (*value < 1000) {
embb::mtapi::Task task = node.Spawn( embb::tasks::Task task = node.Spawn(
embb::base::Bind( embb::base::Bind(
testRecursiveTaskAction, value, embb::base::Placeholder::_1)); testRecursiveTaskAction, value, embb::base::Placeholder::_1));
task.Wait(MTAPI_INFINITE); task.Wait(MTAPI_INFINITE);
...@@ -59,7 +59,7 @@ static void testRecursiveTaskAction( ...@@ -59,7 +59,7 @@ static void testRecursiveTaskAction(
PT_EXPECT(*value == 1000); PT_EXPECT(*value == 1000);
} }
static void testErrorTaskAction(embb::mtapi::TaskContext & context) { static void testErrorTaskAction(embb::tasks::TaskContext & context) {
context.SetStatus(MTAPI_ERR_ACTION_FAILED); context.SetStatus(MTAPI_ERR_ACTION_FAILED);
} }
...@@ -67,17 +67,17 @@ static void testDoSomethingElse() { ...@@ -67,17 +67,17 @@ static void testDoSomethingElse() {
} }
TaskTest::TaskTest() { TaskTest::TaskTest() {
CreateUnit("mtapi_cpp task test").Add(&TaskTest::TestBasic, this); CreateUnit("tasks_cpp task test").Add(&TaskTest::TestBasic, this);
} }
void TaskTest::TestBasic() { void TaskTest::TestBasic() {
//std::cout << "running testTask..." << std::endl; //std::cout << "running testTask..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID); embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::mtapi::ExecutionPolicy policy(false); embb::tasks::ExecutionPolicy policy(false);
PT_EXPECT_EQ(policy.GetAffinity(), 0u); PT_EXPECT_EQ(policy.GetAffinity(), 0u);
PT_EXPECT_EQ(policy.GetPriority(), 0u); PT_EXPECT_EQ(policy.GetPriority(), 0u);
policy.AddWorker(0u); policy.AddWorker(0u);
...@@ -90,7 +90,7 @@ void TaskTest::TestBasic() { ...@@ -90,7 +90,7 @@ void TaskTest::TestBasic() {
PT_EXPECT_EQ(policy.IsSetWorker(1), true); PT_EXPECT_EQ(policy.IsSetWorker(1), true);
std::string test; std::string test;
embb::mtapi::Task task = node.Spawn( embb::tasks::Task task = node.Spawn(
embb::base::Bind( embb::base::Bind(
testTaskAction, "simple", &test, embb::base::Placeholder::_1)); testTaskAction, "simple", &test, embb::base::Placeholder::_1));
testDoSomethingElse(); testDoSomethingElse();
...@@ -129,7 +129,7 @@ void TaskTest::TestBasic() { ...@@ -129,7 +129,7 @@ void TaskTest::TestBasic() {
status = task.Wait(MTAPI_INFINITE); status = task.Wait(MTAPI_INFINITE);
PT_EXPECT(MTAPI_ERR_ACTION_FAILED == status); PT_EXPECT(MTAPI_ERR_ACTION_FAILED == status);
embb::mtapi::Node::Finalize(); embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0); PT_EXPECT(embb_get_bytes_allocated() == 0);
//std::cout << "...done" << std::endl << std::endl; //std::cout << "...done" << std::endl << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment