Previous: Geometric dependencies and topological sorting, Up: Transactions and topological sorting

6.3.4 Using topological sorting

     void tsort_start(struct obj_tlo * tlo);
     void tsort_is_active(struct obj_tlo *tlo);
     void tsort_end(struct obj_tlo *tlo);

The topological sorting is started by calling the tsort_start function for a page. This function sets up the OF_TSORT_ACTIVE flag. Calling it when the sorting is active is forbidden. The tsort_is_active function can be used to detect whether the sorting is active.

When the sorted list is no longer needed, the sorting should be deactivated by calling the tsort_end function.

     void tsort_insert(struct go *go, struct obj_tlo *tlo);
     void tsort_insert_group(struct go_group *group, struct obj_tlo *tlo);
     void tsort_insert_selected(struct go_group *group, struct obj_tlo *tlo);
     void tsort_insert_hanger(struct hanger *h, struct obj_tlo *tlo);

These functions insert an object(s) together with all the dependent ones into the sorted list. The tsort_insert_hanger function does not insert a hanger but the hanger's parent GO.

If the given objects are already in the list, nothing is done. Calling these functions when the sorting is active is forbidden.

     void tsort_insert_flag(struct go *go, struct obj_tlo *tlo);
     void tsort_insert_group_flag(struct go_group *group, struct obj_tlo *tlo);
     void tsort_insert_selected_flag(struct go_group *group,
                                     struct obj_tlo *tlo);
     void tsort_insert_local_selected_flag(struct go_group *group,
                                           struct obj_tlo *tlo);

Some operations need a set of GOs in topological order as the input. But in the sorted list, there are the dependent objects as well; in that case it is necessary to mark all explicitly inserted GOs by a flag GOF_TSORT. To insert some objects with flags, use these functions instead of the previous ones.