Marc Lehmann wrote:
On Wed, Jul 02, 2008 at 01:46:36PM +0300, vvvua <[EMAIL PROTECTED]> wrote:
  
Default loop  also maintain an  async io on sockets. The program  
architecture  is designed with only one point of realisation of async  
calls - in ev_loop (loop,0) with default loop;
    

It is totally unclear to me what you mean with "async io" - i assume this
is something in your program?
  
Yes. I mean input/output with sockets
 ev_io_init (eh->getEvP(), func, sfd, flags);
 ev_io_start (loop, eh->getEvP());
  
First, i create a timer at 45sec.
After each callback, i am trying to set timer on 5 seconds, but timer  
waits 45 seconds.
    

You should probbaly show the code for that.
Original code too big to show, but simple example is
  
for(int i=100;i>0;i-=10)
{
  LocalOpcodeData *ldt = new LocalOpcodeData();
  ldt->opcode=1;
  set_timeout(fd, i,ldt);
}

  
   TimeSockMapper()
   {
       memset(&tm,0,sizeof(ev_timer));
       memset(&repeat,0,sizeof(ev_tstamp));
    

You do not need to zero-initialise the watcher structures, this will only
bloat your code.
  
ok, i'll remove it.
  
void timeout_cb(EV_P_ struct ev_timer *w_, int revents)
{
   int cfd;
   struct TimeSockMapper * w= (struct TimeSockMapper *)w_;
   struct LocalOpcodeData * ldata = (struct LocalOpcodeData *) w->defPoint;
   cfd=w->fd;

   ev_timer_stop(loop,(ev_timer * )w);
    

No restart here.
  
it's ok
  
void set_timeout(int fd, long long seconds,LocalOpcodeData *ldata)
{
   TimeSockMapper *mtm=new TimeSockMapper();
   mtm->repeat=0;
   mtm->fd=fd;
   mtm->defPoint=ldata;


   ev_timer_init (&(mtm-> tm), timeout_cb, seconds, 0.);
   ev_timer_set (&(mtm-> tm), seconds + ev_now (loop) - ev_time (), 0.);
   ev_timer_start (loop,&(mtm->tm));

    

No restart here either.
  
that's also ok.
If the timer indeed doesn't restart as you want, then you should show us
the code that actually resets the timer and restarts it - make sure you
stop the timer before modifying it, or, even better, use ev_timer_restart
and a suitable restart interval.

  
ev_loop is in different thread. Is this a problem?
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to