0 Replies
      Latest reply on Dec 20, 2019 5:36 PM by tigress
      tigress Level 1 Level 1 (0 points)



        I'm trying to spawn three threads from three classes. However, they  terminate with a SIGABRT and this message:


        Starting CORE

        Performing initialization of threads

        Initializing CORE 1.0

        Initializing TaskManager thread.

        Initialization of Event Manager

        libc++abi.dylib: Initializing Message Manager thread.




        My main code is in the "CORE":

        #ifndef Core_hpp
        #define Core_hpp
        #include <stdio.h>
        #include "TaskManager.hpp"
        #include "EventManager.hpp"
        #include "Scheduler.hpp"
        #include "MessageManager.hpp"
        #include <thread>
        #include "Sampler.hpp"
        class Core
           void initialize()
                cout << "Initializing CORE 1.0" << endl;
                 std::thread task_thread((TaskManager()));
                std::thread event_thread((EventManager()));
                //std::thread scheduler_thread(scheduler);
                std::thread message_thread((MessageManager()));
                //std::thread sampler_thread((Sampler()));
            void update_loop()
            TaskManager taskManager;
            EventManager eventManager;
            Scheduler scheduler;
            MessageManager messageManager;
            Sampler sampler;
        #endif /* Core_hpp */


        and for example, one of the threads is:

        ifndef EventManager_hpp
        #define EventManager_hpp
        #include <stdio.h>
        #include "Message.hpp"
        #include "Event.hpp"
        #include <queue>
        #include <iostream>
        /* GAME GEMS BOOK 3 SECTION 1.1*/
         The Event Manager is the heart of the scheduler. Each task in the task manager
         defines one or more events that it handles. An event is a moment in time
         when a task is to be executed. The event manager generates events as needed
         to trigger the execution of tasks.
        using namespace std;
        class EventManager
            void add(Event e);       //add Event to Event Queue
            void remove(Event e);
            Event retreive(Event e);
            void update();          //
            void calculate_fire_time();
            void add(Message &m, Entity &e); //constructs an event and adds it to the events_queue
            void run();
            void stop();            //flags as halted, blocks remove function from manager
            void operator()() const
                std::cout << "Initialization of Event Manager" << endl;
            bool halted;
            queue<Event> events_queue;
            Event wrap_event(Message &msg, Entity &e);
        #endif /* EventManager_hpp */


        Can somebody tell me what is wrong?