Re: how to defer an event notification

2013-10-20 Thread Marc Lehmann
On Sat, Oct 19, 2013 at 06:52:48PM +, "Srini Gurusu (sgurusu)" 
 wrote:
> >watcher is the relatively costly memory synchronisation done by
> >ev_async_send.
> 
> For simplicity, if I use ev_sync_send(),
> Do we need to protect ev_sync_send() as this will be called by producer
> and 
> consumer as well on the same loop/watcher.

As long as the loop exists and the watcher is started, you should be able
to call ev_async_send at any time without any protection - same thread,
other thread, signal handler, inside a callback, outside a callback etc.
should all be fine.

It's the only function in libev that allows this.

-- 
The choice of a   Deliantra, the free code+content MORPG
  -==- _GNU_  http://www.deliantra.net
  ==-- _   generation
  ---==---(_)__  __   __  Marc Lehmann
  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev


Re: how to defer an event notification

2013-10-19 Thread Srini Gurusu (sgurusu)


On 10/19/13 9:09 AM, "Marc Lehmann"  wrote:

>On Fri, Oct 18, 2013 at 01:49:09PM +, "Srini Gurusu (sgurusu)"
> wrote:
>> I am using async watchers ( one per each queue with priority associated
>>).
>> Can I call ev_async_send() within the async watcher callback context to
>>defer(resend within consumer context on behalf of producer) the
>>remaining processing at later time?
>
>Ok, it's not absolitely clear to me what you are trying to do, but I
>assume
>that your watcher sometimes decides that it doesn't want to do things now,
>but only in the next iteration of the event loop.

Yes, this is what exactly I wanted to.

>
>The fastest way would probably to start an ev_check watcher, which is then
>invoked after polling for new events (or ev_prepare, which is invoked
>after all other callbacks in the current iteration).

Thanks for the suggestions. I would try this.

>
>It is entirely fine to call ev_async_send from within the ev_async
>callback,
>too - the callback will then simply be invoked in the next iteration. The
>only drawback over an ev_check (or even ev_idle, depending on your
>semantics)
>watcher is the relatively costly memory synchronisation done by
>ev_async_send.

For simplicity, if I use ev_sync_send(),
Do we need to protect ev_sync_send() as this will be called by producer
and 
consumer as well on the same loop/watcher.

>
>-- 
>The choice of a   Deliantra, the free code+content
>MORPG
>  -==- _GNU_  http://www.deliantra.net
>  ==-- _   generation
>  ---==---(_)__  __   __  Marc Lehmann
>  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
>  -=/_/_//_/\_,_/ /_/\_\


___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev


Re: how to defer an event notification

2013-10-19 Thread Marc Lehmann
On Fri, Oct 18, 2013 at 01:49:09PM +, "Srini Gurusu (sgurusu)" 
 wrote:
> I am using async watchers ( one per each queue with priority associated ).
> Can I call ev_async_send() within the async watcher callback context to 
> defer(resend within consumer context on behalf of producer) the remaining 
> processing at later time?

Ok, it's not absolitely clear to me what you are trying to do, but I assume
that your watcher sometimes decides that it doesn't want to do things now,
but only in the next iteration of the event loop.

The fastest way would probably to start an ev_check watcher, which is then
invoked after polling for new events (or ev_prepare, which is invoked
after all other callbacks in the current iteration).

It is entirely fine to call ev_async_send from within the ev_async callback,
too - the callback will then simply be invoked in the next iteration. The
only drawback over an ev_check (or even ev_idle, depending on your semantics)
watcher is the relatively costly memory synchronisation done by
ev_async_send.

-- 
The choice of a   Deliantra, the free code+content MORPG
  -==- _GNU_  http://www.deliantra.net
  ==-- _   generation
  ---==---(_)__  __   __  Marc Lehmann
  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev


how to defer an event notification

2013-10-18 Thread Srini Gurusu (sgurusu)
Hi libev experts,

I am migrating my application from singled threaded non locking, event-lib, 
which is used in isc/bind to libev.

My application modeled in multi-threaded  with n-producers and one consumer,  
each thread has its own core (totally n+1 cores).
Each producer sends data over private queues ( not shared among producers ) and 
notifies the consumer over exclusive watcher.
Consumer has to process all the queues based on priority events.

I am using single loop which has to serve all the producers and each event is 
handled in run-to-completion mode but with a timing constraint, in which the 
event has to be processed or deferred. Worker-thread is not  an option for me 
due to obvious reasons.

I am using async watchers ( one per each queue with priority associated ).
Can I call ev_async_send() within the async watcher callback context to 
defer(resend within consumer context on behalf of producer) the remaining 
processing at later time?

Is there a better way of doing this? Any suggestions?

Thanks,
Srini


___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev