[AD] [ alleg-Bugs-2333410 ] think of a way to allocate user event type numbers.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Bugs item #2333410, was opened at 2008-11-23 16:40
Message generated for change (Comment added) made by eglebbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=2333410&group_id=5665

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core Library
Group: 4.9
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Milan Mimica (mmimica)
Assigned to: Nobody/Anonymous (nobody)
Summary: think of a way to allocate user event type numbers.

Initial Comment:
Find a clever way to allocate a unique number for a user event type. Currently users freely choose the numbers which can easily lead to collisions between libs (and parts of allegro itself).

----------------------------------------------------------------------

>Comment By: Evert Glebbeek (eglebbk)
Date: 2008-11-27 02:52

Message:
How about:

static int allocated_user_events = 100;

int al_get_free_user_event_id(void) // Needs a better name
{
   return allocated_user_events++;
}

That way events 0-99 are "reserved" (although we can of course always
increase this if we need to).
I think this is the easiest and most straightforward way to do it. The
only thing to watch out for is multiple threads requesting event IDs at the
same time, although I suspect this wouldn't be a major problem in practice
if we leave it be. For good measure it should probably have a mutex lock in
there though.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=2333410&group_id=5665




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/