Post

Replies

Boosts

Views

Activity

cin is not blocking (C++)
HiI'm trying to write a little text based application and this is my code: void loop() { std::string selection; cout << "Initializing Manual Sampler Thread" << endl; while(true) { cout << "Command:" << endl; cin.clear(); cin >> selection; cout << "<<selection" << selection << endl; }But it comes out as:Shadow Engine (RavenTek) Version 1.0 Build 1.0Developed by Twilight Raven Games-------------------------------------Starting COREPerforming initialization of threadsHost a game? (Y/N)yHost game?Core intializingInitializing CORE 1.0Initializing Clock threadInitializing Task Manager ThreadInitializing Event Manager ThreadIntializing Scheduler ThreadInitializing MessageManager threadInitializing Manual Sampler ThreadCommand:<<selectionyCommand:Program ended with exit code: 0It is supposed to block on cin where it says the command prompt but instead it juststeamrolls right through it.
1
0
664
Dec ’19
Dylib Error in Xcode
HiI'm trying to add two dylibs to XCODE 11, glfw is one of them The other is glm_shared. They are both dylibs and I have them copied to a Frameworks folder. When I build I get the message "library not found for -lglmshared_shared". I used o-tool andotool -D libglm_shared.dyliblibglm_shared.dylib:@rpath/libglm_shared.dylib
0
0
548
Dec ’19
Question about multithreading
HiI have a bunch of threads I want to have interacting but I don't know how to access a thread after I initializeit. I"m coding in C++.For example: Clock ck; std::thread clock_thread(&Clock::loop, &ck); clock_thread.detach();How do I get to modify the Clock's thread from say, my Message thread.
5
0
571
Dec ’19
SIGABRT
HiI'm trying to spawn three threads from three classes. However, they terminate with a SIGABRT and this message:Starting COREPerforming initialization of threadsInitializing CORE 1.0Initializing TaskManager thread.Initialization of Event Managerlibc++abi.dylib: Initializing Message Manager thread.terminating(lldb)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 { public: void initialize() { cout << "Initializing CORE 1.0" << endl; std::thread task_thread((TaskManager())); //task_thread.join(); std::thread event_thread((EventManager())); //event_thread.join(); //std::thread scheduler_thread(scheduler); std::thread message_thread((MessageManager())); //message_thread.join(); //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 { public: 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; while(true) { } } private: bool halted; queue<Event> events_queue; Event wrap_event(Message &msg, Entity &e); }; #endif /* EventManager_hpp */Can somebody tell me what is wrong?
0
0
382
Dec ’19