Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:plans [2014/01/21 10:34] – [with-policy] winkler | doc:plans [2015/05/11 17:06] (current) – gkazhoya | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | //**Note:** this page is deprecated. Please use [[tutorials: | ||
| + | |||
| ====== Writing Plans ====== | ====== Writing Plans ====== | ||
| Line 57: | Line 59: | ||
| | | ||
| | | ||
| - | | + | |
| (with-named-policy ' | (with-named-policy ' | ||
| (loop do (format t "Main loop cycle.~%" | (loop do (format t "Main loop cycle.~%" | ||
| Line 68: | Line 70: | ||
| When policy instances by the names '' | When policy instances by the names '' | ||
| <code lisp> | <code lisp> | ||
| - | (with-policiescan | + | (with-policies |
| ((my-policy-object (3 1)) | ((my-policy-object (3 1)) | ||
| | | ||
| | | ||
| - | (body-code))Right now, just a `timeout-policy` is available that the given `body` stops code after a given amount of time (in seconds) if it hasn't finished by then. | + | (body-code)) |
| - | + | ||
| - | Use it like this: | + | |
| - | ```lisp | + | |
| - | (with-policy cpl: | + | |
| - | (body-code-goes-here)) | + | |
| - | ``` | + | |
| - | And for catching the check condition when the timeout actually happens: | + | |
| - | ```lisp | + | |
| - | (with-failure-handling | + | |
| - | ((policy-check-condition-met (f) | + | |
| - | (declare (ignore f)) | + | |
| - | (handle-error-here-and-maybe-retry))) | + | |
| - | (with-policy cpl: | + | |
| - | (body-code-goes-here))) | + | |
| - | ``` | + | |
| </ | </ | ||
| In this example, the resulting code will be equivalent to the following: | In this example, the resulting code will be equivalent to the following: | ||
| <code lisp> | <code lisp> | ||
| - | (with-policy my-policy-object (3 1)is available that the given | + | (with-policy my-policy-object (3 1) |
| (with-policy my-policy-object (100 4) | (with-policy my-policy-object (100 4) | ||
| (with-policy my-other-policy-object (" | (with-policy my-other-policy-object (" | ||
| (body-code)))) | (body-code)))) | ||
| - | </ | + | </ |
| - | The same princple applies to '' | + | The same princple applies to '' |
| <code lisp> | <code lisp> | ||
| (with-named-policies | (with-named-policies | ||
| Line 105: | Line 92: | ||
| (body-code)) | (body-code)) | ||
| </ | </ | ||
| - | This results in: | + | This results in the same behavior as: |
| <code lisp> | <code lisp> | ||
| (with-named-policy ' | (with-named-policy ' | ||
| Line 115: | Line 102: | ||
| === Built-in Policies === | === Built-in Policies === | ||
| == timeout-policy == | == timeout-policy == | ||
| - | When a piece of code only has a limited maximum amount of time for execution (and must be aborted after that duration), the '' | + | When a piece of code only has a limited maximum amount of time for execution (and must be aborted after that duration), the '' |
| Use it like this: | Use it like this: | ||

