[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Putting event on the top of the queue
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Putting event on the top of the queue
- From: Gordiychuck Oleg <mybrokenbeat@xxxxxxxxx>
- Date: Wed, 27 Apr 2011 01:10:32 +0300
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 26 Apr 2011 18:10:42 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:content-type:content-transfer-encoding :subject:date:message-id:to:mime-version:x-mailer; bh=TznMdm5Dz3SVlUgCj5pJrZ+NwrjDDDTGLcX9/nRRqp4=; b=m5yHWs30FR2KXO+Pu5+jGd5udr3niQOYPp1w5jBRXyDll660Oyt4EubRnV/YNs/6a/ XXiJDwbFxqAnxCvhQ6XSnDrjikZ4RbnxwiJOkoknxxa4tARZkRKBjU9hh100WyxoNXNr WuDjskLianavJmnfaK8bHXSTT/4l1aN9Vazuw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=ZtrgaJg+bS8ExLKK+dKF+H9OsTFxd2FgCYPEn1pyUwCct+UKz1kqh+RmFKX7gDQzNT TK0xrknRaizVflr0Bcmxg2w9BXWu/PV6bGIgvXZPM7wemv/sI/3CNrd50tUDzXJZHyJN 2ch0rB7MLgMfU72MAo6MS0L7iLX2zDvPGnwyk=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hello!
I'm using event2 libs and i want to know if it is possible to put new event on the top of the queue.
For example, i have next events queue:
ev1 -> ev2 -> ev3
While processing ev1 an error occured. Now i want to create new event(err_ev) that will close all application's modules and insert it before ev2.
ev1 -> err_ev -> ev2-> ev3
So i'll be able to free all allocated data in ev1 and close application "normally".
Some pseudo-code:
void ScheduleFree()
{
event *ev;
ev = event_new(base,-1,EV_TIMEOUT,err_ev,data);
event_base_set(base,ev);
}
void ev1()
{
uint8_t *some_awesome_data = (uint8_t*)malloc(100);
... do some stuff
if (error)
{
ScheduleFree();
free(some_awesome_data);
return;
}
... do some stuff
free(some_awesome_data);
}
void err_ev()
{
... stop all modules and free data
event_base_free(base);
}
Unfortunately, event_new will put ev to end of the queue. Is there any method to put event exactly after ev1? Or may be, is there another solution that avoids such memory leaks? (stl::auto_ptr or boost::scoped_ptr also will not solve this problem)
Thank you, for attention!
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.