Advertisement

Questions about the Event Manager

Started by August 19, 2021 05:57 PM
20 comments, last by h8CplusplusGuru 3 years, 3 months ago

Rewaz said:
Yes, but Windows (OS) takes 2GB of RAM, so only 2GB are free for us to use (AFAIK).

True, but this is still Virtual Memory from everything running in the background. You should take a read about Windows swpafile feature ?

Rewaz said:
So something like the vector, resize it, and use data() to get the memory?

For example. We're using our own Array type as base for every data container in our engine instead of STL stuff. You may also take a look at the EA STL library

I don't know if delegates can get simpler than the following:


class EventManager{

	typedef std::function<void( void) > ActionType;

	std::queue<ActionType> mEventQueue;
public:

	template<typename Action>
	void pushEvent( Action action ){
		mEventQueue.push_back(action);
	}


	void processOne(){
		
		auto& action = mEventQueue.front();
		action();
		mEventQueue.pop_front();

	}

};



void foo(){

	vec3 pos;

	eventManager.pushEvent( [&](){
		
		delegateCode(pos);//could be inline		
	});

	eventManager.pushEvent( [x,y,z](){

		delegateCode2(x,y,z);
	};
}

this isn't fast enough or doesn't meet requirements?

This topic is closed to new replies.

Advertisement