bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch for join and periodic timers from Jakob Scov-Pedersen


From: David Sugar
Subject: Re: patch for join and periodic timers from Jakob Scov-Pedersen
Date: Mon, 23 Dec 2002 07:57:17 -0500
User-agent: KMail/1.4.3

I think this is a good patch and that makes some degree of sense.  We don't 
make much use of timers in Common C++ since they are not very portable but 
where they do work, this is useful.

On Monday 23 December 2002 04:41, Federico Montesino Pouzols wrote:
> Hi, Jakob Skov-Pedersen has recently submitted thrugh savannah
> the patch included below. It adds a new method (Thread::join) and a
> bool parameter for setTimer, which allows for setting a periodic
> timer.
>
>       Since there has been a discussion about threads, some people
> may have comments about this patch. I would apply it for both the next
> 1.0 release and the 1.1 release, just adding a comment stating that
> the periodic timer will be available only where itimer is available,
> and adding the 'false' default value for the bool parameter of
> setTimer.
>
> -----------
>
> diff -rc2P commoncpp2-1.0.7/ChangeLog commoncpp2-1.0.7-jasp2/ChangeLog
> *** commoncpp2-1.0.7/ChangeLog        Mon Nov 25 20:38:32 2002
> --- commoncpp2-1.0.7-jasp2/ChangeLog  Thu Dec  5 19:50:35 2002
> ***************
> *** 1,2 ****
> --- 1,4 ----
> + From 1.0.7 to 1.0.7-jasp
> + - timer in PosixThread can now be periodic, I think
>   From Common C++ 2 1.0.6 to 1.0.7
>   - socketport attach() stuff.
> diff -rc2P commoncpp2-1.0.7/include/cc++/thread.h
> commoncpp2-1.0.7-jasp2/include/cc++/thread.h ***
> commoncpp2-1.0.7/include/cc++/thread.h        Sun Nov 10 05:19:36 2002 ---
> commoncpp2-1.0.7-jasp2/include/cc++/thread.h  Thu Dec  5 20:18:51 2002
> ***************
> *** 1069,1072 ****
> --- 1069,1073 ----
>       friend class Slog;
>
> +     Semaphore joinSem;
>       static Thread* _main;
>
> ***************
> *** 1341,1344 ****
> --- 1342,1350 ----
>
>       /**
> +      * Blocking call which unlucks when thread terminates
> +      */
> +     void join(void);
> +
> +     /**
>        * Get exception mode of the current thread.
>        *
> ***************
> *** 1475,1480 ****
>        *
>        * @param timer timeout in milliseconds.
>        */
> !     void setTimer(timeout_t timer);
>
>       /**
> --- 1481,1487 ----
>        *
>        * @param timer timeout in milliseconds.
> +      * @param recuring should the timer be periodic
>        */
> !     void setTimer(timeout_t timer, bool periodic);
>
>       /**
> diff -rc2P commoncpp2-1.0.7/src/thread.cpp
> commoncpp2-1.0.7-jasp2/src/thread.cpp ***
> commoncpp2-1.0.7/src/thread.cpp       Sun Nov 10 05:19:37 2002
> --- commoncpp2-1.0.7-jasp2/src/thread.cpp     Thu Dec  5 20:25:10 2002
> ***************
> *** 276,279 ****
> --- 276,283 ----
>   }
>
> + void Thread::join(void) {
> +     joinSem.wait();
> + }
> +
>   /*
>    * End Suspend/Resume stuff
> ***************
> *** 825,828 ****
> --- 829,833 ----
>               priv->_tid = 0;
>       }
> +     joinSem.post();
>   }
>
> ***************
> *** 1253,1257 ****
>   }
>
> ! void        PosixThread::setTimer(timeout_t timer)
>   {
>       sigset_t sigs;
> --- 1258,1262 ----
>   }
>
> ! void        PosixThread::setTimer(timeout_t timer, bool periodic)
>   {
>       sigset_t sigs;
> ***************
> *** 1263,1266 ****
> --- 1268,1275 ----
>       itimer.it_value.tv_usec = (timer * 1000) % 1000000;
>       itimer.it_value.tv_sec = timer / 1000;
> +     if (periodic) {
> +             itimer.it_interval.tv_usec = itimer.it_value.tv_usec;
> +             itimer.it_interval.tv_sec = itimer.it_value.tv_sec;
> +     }
>   #else
>       timer /= 1000;
>
>
>
> _______________________________________________
> Bug-commoncpp mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-commoncpp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]