[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Help with progress thread
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Help with progress thread
- From: Ralph Castain <rhc@xxxxxxxxxxxx>
- Date: Tue, 9 Nov 2010 13:28:16 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 09 Nov 2010 15:28:26 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:content-type :content-transfer-encoding:subject:date:message-id:to:mime-version :x-mailer; bh=uWGmf2Sz+/THjOe5iY8hqWHwKyt+zVtzP9Vm21M25OA=; b=SMvCeOBudh6EfthSiy/2N18hWJPnPnxROrWEct8VfAHjbrIGVUmvifxapoktzcWqGS 9y9KrQYg3f5PX4AKRq2X28ytgwhBcog26KsJjRqf9Ygmei+kxkh+gfDVEqBgKi5fiGM8 gUAxNdTwXIFdpxivbq4rA+nTqfV+8lg6lii/I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:content-type:content-transfer-encoding:subject:date :message-id:to:mime-version:x-mailer; b=FZEJFTnHCGINJSEC3PigZRySZHVg4vsKBH68Afs4HOZVP3lmY9Q5mNaGmEayOYbR6+ vHbFnWLK+w9aejOA6KmA+cSVN4czLci2oPOCyjtPIyMBU8ynd/hv3oacSO8foey9f9mg aJS2eYECSWaaDQ2XvaryO3Ru0sP70wUF0DV7w=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi folks
I'm running into a problem that probably results from my ignorance. So I figured I would ask if someone can tell me what I'm doing wrong.
I have a thread that loops the event library with the following call:
events += event_loop(mca_oob_tcp_component.event_base, EVLOOP_ONCE);
In another thread, I create and add an event that is supposed to occur when a file descriptor is ready for "write":
event_set(mca_oob_tcp_component.event_base,
&peer->peer_send_event,
peer->peer_sd,
EV_WRITE|EV_PERSIST,
mca_oob_tcp_peer_send_handler,
peer);
event_add(&peer->peer_send_event, 0);
Note that the event_set and event_add can (and in this case, probably do) occur while I am in the event_loop function.
What I find is that this event never gets fired. However, events that are set and added -before- going into the loop do fire.
So my question is: given that this is a dynamic system, how do I get the event_loop to "see" new events? I want to block in the loop, so I don't really want to set NONBLOCK if I can avoid it (otherwise, I would have to add another blocking call somewhere to keep the thread from endlessly cycling).
The only thing I could think of was to (a) create an event looking at a pipe, and then (b) every time I define a new event, send a byte down the pipe to break myself out of the loop, thus allowing the event_loop function to "see" the new event.
Any cleaner alternatives? I figure this -must- be a common problem...
Ralph
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.