#489 - Progressive Tempcode evaluation
| Identifier | #489 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Progressive Tempcode evaluation |
| Status | Closed (rejected) |
| Tags |
Type: Performance (custom) |
| Handling member | Chris Graham |
| Addon | core |
| Description | If Tempcode isn't in some kind of diagnostic mode (showing the Tempcode tree or whatever), then have a new paradigm for Tempcode evaluation in the API. Use this paradigm primarily for outputting the header/panels/blocks before a page finishes executing.
Currently we build up a complete Tempcode tree, and then evaluate it. If we drop the idea of preprocessing (discussed in another issue) we no longer need to do this). Instead of build up the HEADER/GLOBAL/FOOTER templates last, do it first. But obviously the 'MIDDLE' parameter would be unbound at this point, as execution has not finished. We initially call do_template without passing 'MIDDLE'. Then we have a new method on the Tempcode object we call instead of evaluate_echo()... evaluate_echo__until_stalled(). This method iterates over the Tempcode seq_parts until it gets to one that has not been bound. It then quits out, storing where it was. We can then call evaluate_echo__until_stalled(true) again when we know 'MIDDLE' is computed, and it would finish the output [true indicates it now should expect all parameters to be known as we're finishing off -- and give errors if ones missing]. This allows data transfer to be parallel to server-side execution, and reduced memory consumption (theoretically). We can go further and allow output of the MIDDLE component iteratively (e.g. post-by-post for a forum topic). We'd check a global state that asks if we're currently outputting and if we are we call evaluate_echo__until_stalled() on the screen template we're currently building up (like 'GLOBAL' this would need preinitialising with some missing variables calculated later). The pattern in this case would be a bit more complex as we'd be splitting a variable into multiple parts. The code would look something like... $tpl=do_template('CNS_TOPIC_SCREEN',array('TITLE'=>$title,'POSTS'=>NULL)); if (is_outputting_already()) $tpl->evaluate_echo__until_stalled(); foreach ($posts as $post) { $_post=render_post($post); $tpl->extend_binding('MIDDLE',$_post); if (is_outputting_already()) $tpl->evaluate_echo__until_stalled('MIDDLE'); // Tells it 'MIDDLE' is not done yet so to output what it has but not advance the iterator yet } $tpl->mark_fully_bound('MIDDLE'); if (is_outputting_already()) $tpl->evaluate_echo__until_stalled(true); return $tpl; // When attach'd it would have to know that output had happened, stored as a note inside $tpl -- so when evaluate_echo__until_stalled() was called on the global template it would skip over this value for MIDDLE knowing it was done already |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".
Comments