No problem!

You could setup a task queue with 1/s rate and only 1 concurrent task.

When this task gets finished, dispatch the same task again. Sleeping a
thread will probably consume unnecessary resources considering that the
memcache update should only take a few miliseconds (5~10).





On Mon, Jun 27, 2011 at 3:13 PM, [email protected] <
[email protected]> wrote:

> Sounds promising... Should say that I didn't know about the backend service
> so far. I'm starting with GAE, but with a non trivial problem, instead of a
> hello world :-)
>
> Now I just need to be able to update my timers in a second by second
> fashion (there are situations where I need to restart them). As far as I
> could see, Thread.sleep( 1000 ) should not be a problem...
>
> Thanks for the advice Bruno!
>
>
> On Mon, Jun 27, 2011 at 1:35 PM, Bruno Fuster <[email protected]>wrote:
>
>> Right...
>>
>> I'm not sure but you could use the increment method from MemcacheService
>> to atomically update this value each second from a single machine (backends)
>> and read that from your dynamic instances constantly using ajax.
>>
>>
>> http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService.html#increment(java.lang.Object,
>> long)
>>
>>
>>
>> On Mon, Jun 27, 2011 at 1:08 PM, [email protected] <
>> [email protected]> wrote:
>>
>>> I thought on this, but I think this works fine only if I have just one
>>> running copy of my application. If I have two or more (because the workload
>>> can be high), they can be out of sync regarding their local clocks. Thus,
>>> requests that arrive at approximately the same time at the different
>>> instances, can get a different value to the "second" variable...
>>>
>>>
>>>
>>> On Mon, Jun 27, 2011 at 12:58 PM, Bruno Fuster <[email protected]>wrote:
>>>
>>>> You could just put this countdown date into your cache (or even a static
>>>> property if it won't change) and calculate the seconds easily using
>>>> jodatime
>>>>
>>>> int seconds = Seconds.secondsBetween(new DateTime(),
>>>> cache.get(countdownDate)).getSeconds();
>>>>
>>>> After that, use javascript intervals to recalculate the countdown while
>>>> the user is at your page instead of consuming some services on your
>>>> back-end.
>>>>
>>>>
>>>>
>>>>
>>>>  On Mon, Jun 27, 2011 at 12:48 PM, [email protected] <
>>>> [email protected]> wrote:
>>>>
>>>>> Is it possible to implement a global count down timer in GAE/J? I would
>>>>> like an unique timer to be shared among all the application instances. The
>>>>> precision of the timer is seconds.
>>>>>
>>>>> Any idea?
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Google App Engine for Java" group.
>>>>> To post to this group, send email to
>>>>> [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Bruno Fuster
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Google App Engine for Java" group.
>>>> To post to this group, send email to
>>>> [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>
>>
>> --
>> Bruno Fuster
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



-- 
Bruno Fuster

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to