Re: Vibe.d timer - change callback?

2020-08-27 Thread James Blachly via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 18:42:53 UTC, codic wrote: I'd like to be able to change the callback of a vibe.d Timer (eg created with http://vibe-core.dpldocs.info/v1.9.3/vibe.core.core.createTimer.html) after creation, something like: auto timer = createTimer(); timer.rearm(dur

Re: Vibe.d timer - change callback?

2020-08-27 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 18:42:53 UTC, codic wrote: I'd like to be able to change the callback of a vibe.d Timer (eg created with http://vibe-core.dpldocs.info/v1.9.3/vibe.core.core.createTimer.html) after creation, something like: auto timer = createTimer(); timer.rearm(dur

Vibe.d timer - change callback?

2020-08-25 Thread codic via Digitalmars-d-learn
I'd like to be able to change the callback of a vibe.d Timer (eg created with http://vibe-core.dpldocs.info/v1.9.3/vibe.core.core.createTimer.html) after creation, something like: auto timer = createTimer(); timer.rearm(duration, /*...*/); timer.callback = delegate { // things

Re: Using Async task with timer

2019-02-06 Thread Sudhi via Digitalmars-d-learn
On Wednesday, 6 February 2019 at 05:17:51 UTC, Heromyth wrote: On Wednesday, 6 February 2019 at 05:03:26 UTC, Sudhi wrote: Hi All, I am trying to use an Async task which would run at every interval of time. I could not find any example for this. Can some one enlighten me on this. I did not

Re: Using Async task with timer

2019-02-05 Thread Heromyth via Digitalmars-d-learn
On Wednesday, 6 February 2019 at 05:03:26 UTC, Sudhi wrote: Hi All, I am trying to use an Async task which would run at every interval of time. I could not find any example for this. Can some one enlighten me on this. I did not find much documentation on timers also. Thanks, Sudhi Here i

Using Async task with timer

2019-02-05 Thread Sudhi via Digitalmars-d-learn
Hi All, I am trying to use an Async task which would run at every interval of time. I could not find any example for this. Can some one enlighten me on this. I did not find much documentation on timers also. Thanks, Sudhi

Re: Vibe-d issue with timer in separate thread on debug builds

2018-01-18 Thread Andres Clari via Digitalmars-d-learn
On Thursday, 18 January 2018 at 10:03:57 UTC, drug wrote: 18.01.2018 08:45, Andres Clari пишет: I see, then although it works (or it may work) on release shouldn't that assert happen for release builds by default too? Or is the thought that you got the error running the debug build you shoul

Re: Vibe-d issue with timer in separate thread on debug builds

2018-01-18 Thread drug via Digitalmars-d-learn
18.01.2018 08:45, Andres Clari пишет: I see, then although it works (or it may work) on release shouldn't that assert happen for release builds by default too? Or is the thought that you got the error running the debug build you should do it a different way on your own and skip the check all

Re: Vibe-d issue with timer in separate thread on debug builds

2018-01-17 Thread Andres Clari via Digitalmars-d-learn
On Tuesday, 16 January 2018 at 09:04:18 UTC, Sönke Ludwig wrote: Am 10.01.2018 um 15:40 schrieb Andres Clari: Hi, I have an app that uses vibe tasks, fibers and timers extensively, and I found an issue only for debug builds, when canceling a timer. However the code in question works just fine

Re: Vibe-d issue with timer in separate thread on debug builds

2018-01-16 Thread Sönke Ludwig via Digitalmars-d-learn
Am 10.01.2018 um 15:40 schrieb Andres Clari: Hi, I have an app that uses vibe tasks, fibers and timers extensively, and I found an issue only for debug builds, when canceling a timer. However the code in question works just fine in the release build. But having this here makes testing certain

Vibe-d issue with timer in separate thread on debug builds

2018-01-10 Thread Andres Clari via Digitalmars-d-learn
Hi, I have an app that uses vibe tasks, fibers and timers extensively, and I found an issue only for debug builds, when canceling a timer. However the code in question works just fine in the release build. But having this here makes testing certain things in my program a pain, since it&#x

Re: Timer

2016-06-21 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 01:31:17 UTC, Adam D. Ruppe wrote: On Tuesday, 21 June 2016 at 23:15:58 UTC, Joerg Joergonson wrote: Does D have a timer? You could make one with threads or timeouts, or event loop and GUI libraries have one. Like simpledisplay.d has a Timer class http

Re: Timer

2016-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 23:15:58 UTC, Joerg Joergonson wrote: Does D have a timer? You could make one with threads or timeouts, or event loop and GUI libraries have one. Like simpledisplay.d has a Timer class http://dpldocs.info/experimental-docs/arsd.simpledisplay.Timer.html and i&#

Timer

2016-06-21 Thread Joerg Joergonson via Digitalmars-d-learn
Does D have a timer? I've tried some user code and it doesn't work. I need to be able to have a delegate called periodically. (fiber or thread, doesn't matter) https://github.com/Dav1dde/BraLa/blob/master/brala/utils/thread.d module lib.mTimer; private { im

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 12:03:39 UTC, Dejan Lekic wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Here

Re: Timer

2014-02-17 Thread Dejan Lekic
On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Here is a quick timer implementation that you can improve yourself

Re: Timer

2014-02-17 Thread David
Am 17.02.2014 12:20, schrieb Chris: > On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: >> On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: >>> The D way of implementing a timer? I need to (automatically) execute >>> a function that performs

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 11:20:05 UTC, Chris wrote: On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every

Re: Timer

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 11:20:05 UTC, Chris wrote: On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every

Re: Timer

2014-02-17 Thread Chris
On Monday, 17 February 2014 at 11:11:06 UTC, simendsjo wrote: On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Vibe.d

Re: Timer

2014-02-17 Thread simendsjo
On Monday, 17 February 2014 at 11:08:16 UTC, Chris wrote: The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; } Vibe.d can be used for this to get an OS agnostic solution. Haven&#

Timer

2014-02-17 Thread Chris
The D way of implementing a timer? I need to (automatically) execute a function that performs a clean up, say every hour. if (file.older than 1 hour) { remove; }

Re: D timer

2013-02-27 Thread David
Am 26.02.2013 14:19, schrieb bearophile: > David: > >> Not sure what you mean, but I have a pretty solid Timer implementation >> (Threaded) >> >> https://github.com/Dav1dde/BraLa/blob/master/brala/utils/thread.d >> >> The file has no dependencies, so co

Re: D timer

2013-02-26 Thread bearophile
David: Not sure what you mean, but I have a pretty solid Timer implementation (Threaded) https://github.com/Dav1dde/BraLa/blob/master/brala/utils/thread.d The file has no dependencies, so copy it over and have fun. License of the whole application is GPLv3, but if you need it relicensed

Re: D timer

2013-02-26 Thread heromyth
On Sunday, 10 February 2013 at 14:49:15 UTC, SaltySugar wrote: Can i do my own timer in D console application? like in C# timer_Tick event. I have also created one. Please, see here: https://bitbucket.org/heromyth/dtoolkit/src/a8b5f8874e3d82373b71a2ca5c9f02a73362b56a/toolkit/System/Timer.d?at

Re: D timer

2013-02-10 Thread David
Am 10.02.2013 15:49, schrieb SaltySugar: > Can i do my own timer in D console application? > like in C# timer_Tick event. Not sure what you mean, but I have a pretty solid Timer implementation (Threaded) https://github.com/Dav1dde/BraLa/blob/master/brala/utils/thread.d The file

Re: D timer

2013-02-10 Thread rumbu
On Sunday, 10 February 2013 at 14:49:15 UTC, SaltySugar wrote: Can i do my own timer in D console application? like in C# timer_Tick event. There is no Timer in D as you know it from C# and also there are no events. You must rely on SetTimer WinAPI and write your own TimerProc.

Re: Is this a good way of setting up a timer?

2011-06-07 Thread Jonathan M Davis
On 2011-06-03 15:02, Jonathan M Davis wrote: > Incidentally, this use case shows that I should probably add overloads for > some of the basic math functions for Duration... I'm an idiot. I was thinking that min and max were in std.math and specific to built-in types, but we were smarter than that

Re: Is this a good way of setting up a timer?

2011-06-06 Thread Andrej Mitrovic
On 6/6/11, Steven Schveighoffer wrote: > Then, you have a function that sets the bool and signals the condition: > > void endProgram() > { > synchronized(mutex) > { >if(engineActive) >{ >engineActive = false; >cond.notifyAll(); >} > } > }

Re: Is this a good way of setting up a timer?

2011-06-06 Thread Steven Schveighoffer
On Fri, 03 Jun 2011 17:37:40 -0400, Andrej Mitrovic wrote: On 6/3/11, Jonathan M Davis wrote: Generally, you'd just put it to sleep for the period of time that you want to wait for. The only reason that I see to keep waking it up is if it could be interrupted and effectively told to

Re: Is this a good way of setting up a timer?

2011-06-04 Thread Jonathan M Davis
On 2011-06-04 11:14, Andrej Mitrovic wrote: > Hey, so is there a reason I'm not allowed to use immutable here: > > immutable finalTime = Clock.currTime + dur!"seconds"(5); > > Error: cannot implicitly convert expression > (currTime(cast(immutable(TimeZone))opCall()).opBinary(dur(5L))) of > type S

Re: Is this a good way of setting up a timer?

2011-06-04 Thread Andrej Mitrovic
Hey, so is there a reason I'm not allowed to use immutable here: immutable finalTime = Clock.currTime + dur!"seconds"(5); Error: cannot implicitly convert expression (currTime(cast(immutable(TimeZone))opCall()).opBinary(dur(5L))) of type SysTime to immutable(SysTime)

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
I didn't even think about issue #1. Thanks again!

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 14:37, Andrej Mitrovic wrote: > On 6/3/11, Jonathan M Davis wrote: > > Generally, you'd just put it to sleep for the period of time that you > > want to > > wait for. The only reason that I see to keep waking it up is if it could > > be interrupted and effectively told to wake up - i

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
On 6/3/11, Jonathan M Davis wrote: > > Generally, you'd just put it to sleep for the period of time that you want > to > wait for. The only reason that I see to keep waking it up is if it could be > interrupted and effectively told to wake up - in which case you would be > sleeping and waking up o

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 14:22, Andrej Mitrovic wrote: > I can't find any timers in phobos, basically I want some loop to run for a > predetermined amount of time. Currently I use this: > > import core.time; > import std.datetime; > import core.thread; > > void main() > { > auto finalTime = Clock.currTime +

Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
I can't find any timers in phobos, basically I want some loop to run for a predetermined amount of time. Currently I use this: import core.time; import std.datetime; import core.thread; void main() { auto finalTime = Clock.currTime + dur!"seconds"(4); while (true) { Thre

Re: Timer library?

2010-01-25 Thread Pelle Månsson
On 01/25/2010 04:02 PM, strtr wrote: Stanislav Blinov Wrote: Pelle M�nsson wrote: I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least m

Re: Timer library?

2010-01-25 Thread strtr
Lars T. Kyllingstad Wrote: > It's not undocumented, it's just badly linked-to. :) > > http://www.digitalmars.com/d/2.0/phobos/std_perf.html > > -Lars http://www.digitalmars.com/d/1.0/phobos/std_perf.html

Re: Timer library?

2010-01-25 Thread Lars T. Kyllingstad
strtr wrote: Stanislav Blinov Wrote: Pelle M幩sson wrote: I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond resolution, so std.c

Re: Timer library?

2010-01-25 Thread strtr
Stanislav Blinov Wrote: > Pelle Månsson wrote: > > I'm in need for a timer library that measures the acutal time. I have > > tried std.c.time's clock(), but it only measures time spent inside the > > program, not actual time elapsed. > > > >

Re: Timer library?

2010-01-25 Thread Stanislav Blinov
Pelle Månsson wrote: I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond resolution, so std.c.time.time() is not an option. I

Timer library?

2010-01-25 Thread Pelle Månsson
I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond resolution, so std.c.time.time() is not an option. I wonder, is there a good l

Re: Timer in D.API?

2009-03-05 Thread Christopher Wright
Sam Hu wrote: Thank you both so much. In DFL there is a Timer class but I can not get it work: It compiled but just print 2 lines of message: Before timer ... After timer... I am asking Chris Miller on DFL forum regarding this issue. In DWT,there is a Runnable class I think it can gain the same

Re: Timer in D.API?

2009-03-04 Thread Sam Hu
Thank you both so much. In DFL there is a Timer class but I can not get it work: module dflTimer; import dfl.all; import tango.io.Stdout; class LetterPerSecond { private: Timer timer; static int counter; static char[] displayString; void writeChar(Timer sender,EventArgs ea

Re: Timer in D.API?

2009-03-04 Thread Christopher Wright
Steve Schveighoffer wrote: e.g.: import tango.time.Clock; ... auto curTime = Clock.now; auto period = TimeSpan.fromMilliseconds(300); auto nextTime = curTime + period; for(int counter=0;;counter++) { Stdout(displayString[counter%displayString.length]).flush; auto timeToSleep = nextTime - curT

Re: Timer in D.API?

2009-03-04 Thread Steve Schveighoffer
On Tue, 03 Mar 2009 23:10:07 -0500, Sam Hu wrote: > First of all,this is about D ,not C#. In C# the program print each > letter of a string per 0.3 second one by one using the Timer & delegate: > C# code: > using System; > using System.Text; > using System.Timers; > &

Timer in D.API?

2009-03-03 Thread Sam Hu
First of all,this is about D ,not C#. In C# the program print each letter of a string per 0.3 second one by one using the Timer & delegate: C# code: using System; using System.Text; using System.Timers; namespace OneLetterATime { class Program { static int counter