🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Questions about the Event Manager

Started by
20 comments, last by h8CplusplusGuru 2 years, 9 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

Advertisement

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