# A custom method for events [closed]

Basically what I am trying to do here is to create an event system for a simple game engine I am working on.

I'm trying to make this program as platform independent as possible with the C++ language so I am ruling out threading for the moment.

The basic idea that is that:

//outside game loop (initialization)
o_check_for_events(O_CHECK_ALL_EVENTS); // this should add the events to some sort of list

// inside game loop
event = o_get_next_event(); // return the next event in the queue
// ..
// do stuff with events


That would be a sample game event loop. What I want out of this though is an option that I can ask the system to wait for an event (easier of the two) and/or be able to check for events even while the game is running.

What I want to know is if it is more efficient to have methods that interrupt the flow for a short period of time, or else a threaded program that checks for events simultaneously (assume that the thread functions are safe)?

## closed as off-topic by bummzack, Sean Middleditch, Anko, MichaelHouse♦Sep 18 '13 at 23:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – bummzack, Sean Middleditch, Anko, MichaelHouse
If this question can be reworded to fit the rules in the help center, please edit the question.

• Why do your functions start with o_? Also, C++ has platform-independent threading facilities, which you will find in <thread> header. Also, what do you mean by "more efficient?" – Bartek Banachewicz Sep 16 '13 at 14:56
• @BartekBanachewicz the o_ is just a naming convention in the project. – PurityLake Sep 16 '13 at 15:22
• Then it's a bad convention. A namespace should be used instead. What about my other points? – Bartek Banachewicz Sep 16 '13 at 15:32
• I don't see what the problem is with the convention. and by more efficient I mean which will be able to deliver messages quicker while also using as little resources as possible i.e. processing power and memory – PurityLake Sep 16 '13 at 15:36
• Have you profiled the current method to see if it's really a hotpath in the execution? The problem with the convention is that it introduces unnecessary noise and doesn't really help with name clashes; both of those problems can be easily solved with a namespace. Have you taken a look at C++'s threading/async model? – Bartek Banachewicz Sep 16 '13 at 15:39

• I see what you are saying. I think I can come up with something using what you just said. Also its just a naming convention, that methods to do with the engine named Orpheus (not my idea) begin with o_ then the rest is also seperated by _ e.g. do_something() – PurityLake Sep 16 '13 at 15:24