Update Timer?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Update Timer?

Kirk Fraser
I am building a simple database using a tree and a ReferenceStream as learned here.  I want it to update the disk file every 10 min. with the current tree.  What should I do?

The classes Time, Duration, Stopwatch, Schedule, look like possibilities but the only method that looks good is Schedule "between: aStart and: anEnd do: aBlock" but I don't want it to hang waiting on the timer so the tree can't take my changes.  How do I make something perform like a text editor that saves its work every 10 min?

Thanks,

Kirk Fraser

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Update Timer?

Kirk Fraser
Sleeping on a problem helped in this case.

Time current minutes < timer minutes + 10
ifTrue: [^#waiting].
timer := Time current.

I put that in an update method called by methods that change the data.  Not guaranteed every 10 min depending on user behavior but close enough and easier than defining a process.


On Fri, May 1, 2015 at 10:14 PM, Kirk Fraser <[hidden email]> wrote:
I am building a simple database using a tree and a ReferenceStream as learned here.  I want it to update the disk file every 10 min. with the current tree.  What should I do?

The classes Time, Duration, Stopwatch, Schedule, look like possibilities but the only method that looks good is Schedule "between: aStart and: anEnd do: aBlock" but I don't want it to hang waiting on the timer so the tree can't take my changes.  How do I make something perform like a text editor that saves its work every 10 min?

Thanks,

Kirk Fraser


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Update Timer?

Kirk Fraser
Woops!  What if timer + 10 gets bigger than 60? 

Time current - timer < 10 

When you can't get help, help yourself! 

On Sat, May 2, 2015 at 10:21 PM, Kirk Fraser <[hidden email]> wrote:
Sleeping on a problem helped in this case.

Time current minutes < timer minutes + 10
ifTrue: [^#waiting].
timer := Time current.

I put that in an update method called by methods that change the data.  Not guaranteed every 10 min depending on user behavior but close enough and easier than defining a process.


On Fri, May 1, 2015 at 10:14 PM, Kirk Fraser <[hidden email]> wrote:
I am building a simple database using a tree and a ReferenceStream as learned here.  I want it to update the disk file every 10 min. with the current tree.  What should I do?

The classes Time, Duration, Stopwatch, Schedule, look like possibilities but the only method that looks good is Schedule "between: aStart and: anEnd do: aBlock" but I don't want it to hang waiting on the timer so the tree can't take my changes.  How do I make something perform like a text editor that saves its work every 10 min?

Thanks,

Kirk Fraser



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners