Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

SimpleEvent

nanonyme edited this page Mar 2, 2011 · 2 revisions

SimpleEvent

Event

Short description

Event loop processes these. They are pretty much continuations.

Constructor

The required first parameter is a lambda function which defines how the event is supposed to behave when it gets executed. The second parameter is not required but keep in mind that if you do not give it, the lambda function is still expected to have one parameter and this will be the event loop itself. The latter behaviour is meant for asynchronous changes for the event loop behaviour itself, like eg telling it to quit when all events have been processed.

execute

No parameters. This will be run by the lambda statement when this Event hits the front of the queue.

recycle

No params. This is a subclassing concern. If you wish to use something different that lambdas for Event objects, you may do so but remember to clean up all references to stored data in __recycle if using EventFactory because otherwise Python memory management might not work optimally

EventFactory

Short description

This produces Event objects. It's also capable of holding a given amount of Event objects in memory so they can be recycled. The storage is configured to store ten Event objects by default.

recycleEvent

Only parameter is the event. It tells the event to clean itself up so storing it will not cause any additional objects to be unnecessarily tored.

createEvent

If there are reusable Event objects in the factory's storage, factory uses them first. If it runs out, it simply creates a new Event object and returns that instead.

setMaxCount

Takes a single positive integer as argument. If more objects are in stored than the new maximum count allows, they are removed. Zero size is allowed, it just means no recycling ever happens

Clone this wiki locally