1

Topic: Autoprogress and autointerruptibility in With ++

It is cast by my post - http://rsdn.org/forum/cpp.applied/7053719.1 the Author: GhostCoders Date: 13.02 14:47 Essence that is necessary to interpose in each "long" method the declaration progress_helper a class, for example so: void process_class (Class& class _) {progress_helper class_progress (school.get_student_count ()); for (student: class _) {process_student (student); class_progress.step ();} } progress_helper carries out  current progress in % with the help , and also checks value from , whether it is necessary to interrupt performance of function or not. If it is necessary, throws out a certain special exception. Manually such methods to write tiresomely. I here think, what if to make on basis clang the extension of the compiler which  the given methods automatically interposed the necessary declarations progress_helper? Naturally, such methods become throwing exceptions. The code: void process_school (School& school) auto_progress {for (class: school.classes ()) {process_class (class);}} void process_class (Class& class _) auto_progress {for (student: class _) {process_student (student);}} void process_stundent (Student& student) auto_progress {process_name (student.name); process_surname (student.surname); process_sex (student.sex);} Turns in void process_school (School& school) {progress_helper school_progress (school.get_class_count(); for (class: school.classes ()) {process_class (class); school_progress.step ();}} void process_class (Class& class _) {progress_helper class_progress (school.get_student_count ()); for (student: class _) {process_student (student); class_progress.step ();}} void process_stundent (Student& student) {progress_helper student_progress (3); process_name (student.name); student_progress.step (); process_surname (student.surname); student_progress.step (); process_sex (student.sex); student_progress.step ();} That tell?

2

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: GC> it is natural, such methods become throwing exceptions. And then there will be a cycle which is caused from , there it will be necessary to forbid exceptions, then still with catch (...) To struggle. In general it does not turn out auto-magics. All problems  from boost:: thread will be. So, I suspect, even without the compiler extension it is possible to make the such: for (class: interruption_points_adapter (school.classes ())) {...} the adapter turns it ++ in check.

3

Re: Autoprogress and autointerruptibility in With ++

Hello, Alexander G, you wrote: AG> And then there will be a cycle which is caused from , there it will be necessary to forbid exceptions, then still with catch (...) to struggle. In  - yes, exceptions to forbid, but  progress it is necessary to leave. And with catch (...) whether it is necessary to struggle somehow still in addition? AG> in general it does not turn out auto-magics. All problems  from boost:: thread will be. Did not work with boost.thread. And it, what, supports interruptibility? AG> so, I suspect, even without the compiler extension it is possible to make the such: AG> AG> for (class: interruption_points_adapter (school.classes ())) AG> {AG>... AG>} AG> AG> the adapter turns it ++ in check. Yes, it is possible. But progress not only on cycles. And on the linear operators of type: void process_stundent (Student& student) auto_progress {process_name (student.name); process_surname (student.surname); process_sex (student.sex);} //which turns in void process_stundent (Student& student) {progress_helper student_progress (3); process_name (student.name); student_progress.step (); process_surname (student.surname); student_progress.step (); process_sex (student.sex); student_progress.step ();} the Plug-in with Clang (extension) calculates that in function process_student () 3 linear calls of others of a method and consequently interposes initialization progress_helper student_progress (3); with constant number 3 (compile time). Generally, interesting, probably such (to calculate number of calls of functions) in compile-time through templates or still somehow? Well to use macroes something in the spirit of void process_stundent (Student& student) {PROGRESS_STEP (process_name (student.name)); PROGRESS_STEP (process_surname (student.surname)); PROGRESS_STEP (process_sex (student.sex));} Not a variant. That is, I think that it cannot be made in compile-time by means of one With ++. Only the extension based on Clang to write?

4

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: GC> It is cast by my post - http://rsdn.org/forum/cpp.applied/7053719.1 the Author: GhostCoders Date: 13.02 14:47 GC> That tell? Apply MVC in some sectional type, basically at you just that task which dares it: separation of logic from data view (progress a bar). If to use two flows, one on algorithm, another on UI all will work. It is possible to try to use  for update and counter display.

5

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: AG>> in general it does not turn out auto-magics. All problems  from boost:: thread will be. GC> did not work with boost.thread. And it, what, supports interruptibility? boost:: thread it is similar on std:: thread (for was a prototype std:: thread), but has the extensions, one of -  points. Any point of interruption throws thread_interrupted an exception if a flow interrupted. Interruption points are explicit calls interruption_point. Besides, some waitings: sleep, the conditional variable, join - all is interruption points. That is, if the flow now waits  waits on the conditional variable, and it interrupted, it takes off there and then. Certainly, works only with primitives from boost, in them waiting on interruption event simultaneously with the main waiting is put. For struggle against exceptions in  create on a stack disable_interruption. For struggle against struggle against exceptions create on a stack restore_interruption. thread_interrupted The exception purposefully is not inherited from std:: exception that it transited through all catch (std::exception&) and completed thread. But if in  is catch (...) he eats thread_interrupted an exception, and instead of the full interruption of a thread it will be simple promotion before catch (...) GC> That is, I think that it cannot be made in compile-time by means of one With ++. Only the extension based on Clang to write? At present is not present, like anything such is not present. Perhaps a preprocessor? Were  on metaclasses, should solve  tasks. For  not anchored to a specific class there were namespace class. My namespace - my rules Only not the fact that comes, and that it in the ending will be enough  not simply to generate methods, and to change existing methods.

6

Re: Autoprogress and autointerruptibility in With ++

Hello, Kernan, you wrote: K> Apply MVC in some sectional type, basically at you just that task which dares it: separation of logic from data view (progress a bar). If to use two flows, one on algorithm, another on UI all will work. It is possible to try to use  for update and counter display. Not absolutely I represent, as it can be separated. Any example?

7

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: GC> Hello, Kernan, you wrote: K>> Apply MVC in some sectional type, basically at you just that task which dares it: separation of logic from data view (progress a bar). If to use two flows, one on algorithm, another on UI all will work. It is possible to try to use  for update and counter display. GC> not absolutely I represent, as it can be separated. Any example? Look, the data about students/classes at you lies in , in the same place certain  progress which is updated after handling iteration, in the controler at you the logic of handling lies where this  increases in the reasonable image, the type is certain  UI which on event of change of model (counter) will draw it on the screen as a variant it is possible on  in UI  to find  the counter and to draw it. For this task interruption point it .

8

Re: Autoprogress and autointerruptibility in With ++

Hello, Kernan, you wrote: K> Look, the data about students/classes at you lies in , in the same place certain  progress which is updated after handling iteration, in the controler at you the logic of handling lies where this  increases in the reasonable image, the type is certain  UI which on event of change of model (counter) will draw it on the screen as a variant it is possible on  in UI  to find  the counter and to draw it. For this task interruption point it . Especially not . But why ? The user pushed button Cancel, and wants that the durable processing procedure of schools \classes \students was interrupted. Yes, UI in one flow, calculations in other. But rigidly to beat a flow with calculations - not . How to be?

9

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: GC> Manually such methods to write tiresomely. GC> that tell? I will tell: you grew lazy. And for data handling to you it will be necessary SQL  to build similar language the execution plan of request and to fulfill it, reporting about the done operation.

10

Re: Autoprogress and autointerruptibility in With ++

Hello, kov_serg, you wrote: _> I Will tell: you grew lazy. So it is possible to tell and about those who uses exceptions. A pier, grew lazy to return the codes of errors and to check the codes of errors from caused methods

11

Re: Autoprogress and autointerruptibility in With ++

Hello, Alexander G, you wrote: AG>... AG> Certainly, works only with primitives from boost, in them waiting on interruption event simultaneously with the main waiting is put. Thanks for the information! AG> thread_interrupted the exception purposefully is not inherited from std:: exception that it transited through all catch (std::exception&) and completed thread. AG> But if in  is catch (...) he eats thread_interrupted an exception, and instead of the full interruption of a thread it will be simple promotion before catch (...) By the way, the extension for Clang can solve it a problem. To analyze the code, and if is catch (...) to interpose hardly above catch (const thread_interrupted&) and anew it . As a result thread_interrupted will pass by catch (...) . AG> For struggle against exceptions in  create on a stack disable_interruption. AG> For struggle against struggle against exceptions create on a stack restore_interruption. Clang extension will not generate burst of exceptions in . And generally through Clang extension there are more than possibilities.

12

Re: Autoprogress and autointerruptibility in With ++

Hello, GhostCoders, you wrote: GC> Clang Extension will not generate burst of exceptions in . Here, probably it is necessary to remember in per-thread a context that we in  and not to throw out an exception. Simply immediately from  to forbid there is not enough,  too can cause methods. As a whole, it will be already similar on.NET-ovskie Thread. Abort Method / ThreadAbortException. There points, whence can take off ThreadAbortException - everywhere, except  the code. Well and from finally the unit caused at promotion, it does not take off (analog With ++ ). With such approach there are problems of that the exception can arise in any place. As it appears, all code provides a basic warranty of exceptions. Leaks of any not-RAII resources, jamming of objects in the forbidden states etc. Here for example there is a sample container vector which at reducing resize causes  in a cycle, what if this cycle to interrupt?