timer

Angular rxjs Observable.interval() not triggering properly on background tabs in Chrome

柔情痞子 提交于 2019-12-12 15:35:58
问题 I am writing angular2 application with interval timers implemented via RxJs observables, and just noticed the strange behaviour of Observable.interval() and Observable.timer() in Chrome browser when tab is in background. Angular component should once every second print number of seconds in console, but on background tabs, this is not working as intended - function triggers every x+1 seconds, where x is interval specified explicitely in the interval funciton Angular component code: ngOnInit()

Do I have to use a signal handler for a Posix timer?

人盡茶涼 提交于 2019-12-12 15:31:58
问题 I want to start a timer and have a function called when it expires. Googling finds lots of examples, including the example in the manual, all of which use sigaction() to set a signal handler. However, @Patryk says in this question that we can just void cbf(union sigval); struct sigevent sev; timer_t timer; sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = cbf; //this function will be called when timer expires sev.sigev_value.sival_ptr = (void*) arg;//this argument will be passed to

how linux's alarm() is handled by kernel

可紊 提交于 2019-12-12 15:07:54
问题 I was reading about how the alarm() call works on the linux. alarm(5) would send a SIGALRM in a minimum of 5 seconds to the process which has made this call. The alarm is caused at that moment thanks to a down counter which is set by the kernel reaching zero. My doubt is here - we can have N number of processes which make an alarm call, and there is one down counter in the system available for this purpose. So the kernel has to keep track of all the processes it has to send a signal to, with

JTable with cell flashing

我的梦境 提交于 2019-12-12 14:44:19
问题 I am writing an application using the Swing library in Java. I have a table component that extends JTable , and in this component I have overridden the method getTableCellRendererComponent , because I color the cells of the table. I have a custom table model (that extends from the default table model), and the table component itself I have added to a JPanel. All this works. Now I would like to add to this table, some functionality to have a cell flashing. Potentially, more than one cell can

unknown type name 'clockid_t'

百般思念 提交于 2019-12-12 14:27:43
问题 I am trying to use C code written on a Linux platform on Mac OS X. I am running into an error related to timers: ../src/stinger/timer.c:61:1: error: unknown type name 'clockid_t' ../src/stinger/timer.c:74:2: error: #error "Cannot find a clock!" which points to this section of code. static clockid_t clockid; #if defined(CLOCK_REALTIME_ID) #define CLKID CLOCK_REALTIME_ID #define CLKIDNAME "CLOCK_REALTIME_ID" #elif defined(CLOCK_THREAD_CPUTIME_ID) #define CLKID CLOCK_THREAD_CPUTIME_ID #define

Using Sleep() while using timers through setitimer

偶尔善良 提交于 2019-12-12 14:07:57
问题 I am using a timer in my C++ code through setitimer function from sys/time.h. This maps the SIGALRM signal to my timer handler method. After this I am not able to use sleep function. I am assuming it is because sleep uses SIGALRM signal as well. Can you suggest any workaround for this problem? Thanks for replying. 回答1: You can try using select() just as a timer. I don't know if it uses SIGALRM or not but it should be simple to test. Something like: timeval t = {1, 0}; select(0, NULL, NULL,

POSIX timer runs at twice the expected frequency

纵然是瞬间 提交于 2019-12-12 13:52:17
问题 In order to create a high accuracy timer, I have written a module that instantiates a POSIX timer using the timer_create() function. It uses CLOCK_REALTIME as its clock kind, SIGEV_SIGNAL as notification method and SIGRTMIN as the signal number. Its signal handler does nothing but a sem_post(). The timer is started using timer_settime(), with any number of milliseconds as the timer interval. The user of the module can wait for a timer-tick; the wait functionality is essentially implemented by

Android equivalent of setTimeout and clearTimeout of javascript?

你离开我真会死。 提交于 2019-12-12 13:12:20
问题 There's an answer for setTimeout https://stackoverflow.com/a/18381353/433570 It doesn't provide info whether we can cancel the timer as we could in javascript. Is there a timer that is cancellable in android? 回答1: According to the documentation of Handler public final void removeCallbacks (Runnable r) Added in API level 1 Remove any pending posts of Runnable r that are in the message queue. Example code: Runnable runnable = new Runnable() { public void run() { Log.i("Tag", "Runnable running!"

Non-blocking sleep timer in C

≯℡__Kan透↙ 提交于 2019-12-12 12:25:27
问题 I'm looking for a good non-blocking sleep timer in C for windows. Currently I am using sleep(10); which of course is a blocking timer. Also I want it to consume no system resources, like my sleep timer it doesn't use any CPU or system resources which I am happy with. So, what is the best non-blocking sleep timer I could use? And please also include an example of how to use it. Thanks. 回答1: You dont need an API you need to change your design. A simple one is this. You can have multiple threads

how to unschedule NSTimer in objective-c

拥有回忆 提交于 2019-12-12 11:10:30
问题 I am using nested NSTimer in an application. I have two issues here. How to re-initiate time counter in this function - (void)updateLeftTime:(NSTimer *)theTimer How to kill previous timer because - (void)updateLevel:(NSTimer *)theTimer is also calling by timer. - (void)viewDidLoad { [super viewDidLoad]; tmLevel=[NSTimer scheduledTimerWithTimeInterval:20.0f target:self selector:@selector(updateLevel:) userInfo:nil repeats:YES]; tmLeftTime=[NSTimer scheduledTimerWithTimeInterval:1.0f target