Commit c6538504 by FritzFlorian

Move error handling into own file.

The current solution is not clean, but allows us to change error handling later on without missing any point in the programm where we would want to use it.
parent 92da43ff
......@@ -14,7 +14,7 @@ add_library(pls STATIC
src/internal/scheduling/run_on_n_threads_task.cpp include/pls/internal/scheduling/run_on_n_threads_task.h
src/internal/scheduling/fork_join_task.cpp include/pls/internal/scheduling/fork_join_task.h
src/internal/base/deque.cpp include/pls/internal/base/deque.h
src/algorithms/invoke_parallel.cpp include/pls/algorithms/invoke_parallel.h)
src/algorithms/invoke_parallel.cpp include/pls/algorithms/invoke_parallel.h include/pls/internal/base/error_handling.h)
# Add everything in `./include` to be in the include path of this project
target_include_directories(pls
......
......@@ -5,6 +5,8 @@
#include <cstdint>
#include <cstdlib>
#include "pls/internal/base/error_handling.h"
namespace pls {
namespace internal {
namespace base {
......@@ -41,7 +43,7 @@ namespace pls {
// Move head to next aligned position after new object
head_ = next_alignment(head_ + sizeof(T));
if (head_ >= memory_end_) {
exit(1); // TODO: Exception Handling
PLS_ERROR("Tried to allocate object on alligned_stack without sufficient memory!");
}
return result;
......
#ifndef PLS_ERROR_HANDLING_H
#define PLS_ERROR_HANDLING_H
#include <iostream>
// TODO: Figure out proper exception handling
#define PLS_ERROR(msg) std::cout << msg << std::endl; exit(1);
#endif //PLS_ERROR_HANDLING_H
#include "pls/internal/scheduling/scheduler.h"
#include "pls/internal/base/error_handling.h"
namespace pls {
namespace internal {
......@@ -9,7 +10,7 @@ namespace pls {
sync_barrier_{num_threads + 1},
terminated_{false} {
if (num_threads > MAX_THREADS) {
exit(1); // TODO: Exception Handling
PLS_ERROR("Tried to create scheduler with more OS threads than pre-allocated memory.");
}
for (unsigned int i = 0; i < num_threads; i++) {
......
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