wiki:0x58unix::Event

Event handlers in 0x58-unix

Event handlers are created in 0x58-unix by implementing the virtual functions found in 0x58-unix/trunk/0x58-unix/Event.h.

Conventions

File naming

Your file names needs to be:

eventUpercasename.{cc,h}

For example, for a poll implementation you need to know your files as such:

eventPoll.{cc,h}

Namespaces/Classes?

The main namespace is x58unix. Inside that namespace is another namespace for implementations named eventImplementation. You will want to use the following in your .h.

namespace x58unix {
    namespace eventImplementation {
        class eventPoll {
            // Rest of class goes here
        }
    }
}

Enroll the event

To have the event system recognise your event you need to enroll it with the systems roll call. This will then allow developers to select the new event handling mechanism.

REGISTER_EVENT(name, weight, class);
name:

This is the name of the class, it will automatically be turned into a const char * and then std::string by the compiler.

weight:

This is the "priority" it should get when the EventFactory? is called. Basically, the higher the weight the more likely it is going to be used as the primary implementation if just a standard event handler is asked for. As of right now the fastest implementation on each platform should get weight 20 (kqueue, epoll, event ports). poll and select will probably get 10, and anything that performs worse than poll/select will get anything less than that. 0 is currently reserved for a dummy event handler that will do absolutely nothing and will just throw errors.

class:

This is the actual class you want to register within the system.

Example

Please note, the name of your event has to be all lower case, and without quotes. You also pass it the class name. So for the example poll implementation you would use the following:

REGISTER_EVENT(poll, 10, x58unix::eventImplementation::eventPoll);