Merge lp:~lsinger/play/1.1 into lp:play/1.1

Proposed by Leif Singer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lsinger/play/1.1
Merge into: lp:play/1.1
Diff against target: 79 lines (+16/-9)
2 files modified
framework/src/play/Invoker.java (+8/-8)
framework/src/play/mvc/Controller.java (+8/-1)
To merge this branch: bzr merge lp:~lsinger/play/1.1
Reviewer Review Type Date Requested Status
play framework developers Pending
Review via email: mp+16676@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leif Singer (lsinger) wrote :

Fixes bug #501665 - Controller.suspend doesn't allow subsecond suspend times.

lp:~lsinger/play/1.1 updated
721. By guillaume <guillaume@gbo-mac>

Merge 1.0

Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

Ok merged. Another cool feature we could provide in this room is:

protected static void waitFor(Future tasks...) {
}

It could wait for several tasks completions before resuming the request.

lp:~lsinger/play/1.1 updated
722. By guillaume <guillaume@gbo-mac>

Merge

Revision history for this message
Leif Singer (lsinger) wrote :

> Ok merged. Another cool feature we could provide in this room is:
>
> protected static void waitFor(Future tasks...) {
> }
>
> It could wait for several tasks completions before resuming the request.

Thanks a lot for merging so quickly! It's nice to have own code in my favorite server-side framework. :)

As for the waitFor for multiple Futures: it looks like it would be useful for some, but then again, I've actually never worked with Futures, so I couldn't even tell whether it works correctly. So I guess I should leave that one to you to decide.

Regards
  Leif

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'framework/src/play/Invoker.java'
--- framework/src/play/Invoker.java 2009-11-17 12:59:06 +0000
+++ framework/src/play/Invoker.java 2009-12-30 15:53:13 +0000
@@ -40,13 +40,13 @@
40 /**40 /**
41 * Run the code in a new thread after a delay41 * Run the code in a new thread after a delay
42 * @param invocation The code to run42 * @param invocation The code to run
43 * @param seconds The time to wait before43 * @param millis The time to wait before, in milliseconds
44 * @return The future object, to know when the task is completed44 * @return The future object, to know when the task is completed
45 */45 */
46 public static Future invoke(final Invocation invocation, int seconds) {46 public static Future invoke(final Invocation invocation, long millis) {
47 Monitor monitor = MonitorFactory.getMonitor("Invocation queue", "elmts.");47 Monitor monitor = MonitorFactory.getMonitor("Invocation queue", "elmts.");
48 monitor.add(executor.getQueue().size());48 monitor.add(executor.getQueue().size());
49 return executor.schedule(invocation, seconds, TimeUnit.SECONDS);49 return executor.schedule(invocation, millis, TimeUnit.MILLISECONDS);
50 }50 }
5151
52 /**52 /**
@@ -64,7 +64,7 @@
64 if (invocation.retry.task != null) {64 if (invocation.retry.task != null) {
65 invocation.retry.task.get();65 invocation.retry.task.get();
66 } else {66 } else {
67 Thread.sleep(invocation.retry.timeout * 1000);67 Thread.sleep(invocation.retry.timeout);
68 }68 }
69 } catch (Exception e) {69 } catch (Exception e) {
70 throw new UnexpectedException(e);70 throw new UnexpectedException(e);
@@ -219,16 +219,16 @@
219 public static class Suspend extends PlayException {219 public static class Suspend extends PlayException {
220220
221 /**221 /**
222 * Suspend for a timeout (in seconds).222 * Suspend for a timeout (in milliseconds).
223 */223 */
224 int timeout;224 long timeout;
225 225
226 /**226 /**
227 * Wait for task execution.227 * Wait for task execution.
228 */228 */
229 Future task;229 Future task;
230230
231 public Suspend(int timeout) {231 public Suspend(long timeout) {
232 this.timeout = timeout;232 this.timeout = timeout;
233 }233 }
234234
@@ -246,7 +246,7 @@
246 if (task != null) {246 if (task != null) {
247 return "Wait for " + task;247 return "Wait for " + task;
248 }248 }
249 return "Retry in " + timeout + " s.";249 return "Retry in " + timeout + " ms.";
250 }250 }
251 }251 }
252252
253253
=== modified file 'framework/src/play/mvc/Controller.java'
--- framework/src/play/mvc/Controller.java 2009-11-22 18:32:54 +0000
+++ framework/src/play/mvc/Controller.java 2009-12-30 15:53:14 +0000
@@ -540,8 +540,15 @@
540 * Suspend the current request for a specified amount of time540 * Suspend the current request for a specified amount of time
541 */541 */
542 protected static void suspend(String timeout) {542 protected static void suspend(String timeout) {
543 suspend(1000 * Time.parseDuration(timeout));
544 }
545
546 /**
547 * Suspend the current request for a specified amount of time (in milliseconds)
548 */
549 protected static void suspend(int millis) {
543 Request.current().isNew = false;550 Request.current().isNew = false;
544 throw new Suspend(Time.parseDuration(timeout));551 throw new Suspend(millis);
545 }552 }
546553
547 /**554 /**

Subscribers

People subscribed via source and target branches