[q-lang-cvs] qcalc calclib.q,1.31,1.32
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-16 08:08:41
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7204 Modified Files: calclib.q Log Message: pass task button update as a quoted taskbutton call instead of a triple; add task_params convenience function to extract the parameters from a quoted taskbutton call Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** calclib.q 16 Nov 2007 07:08:12 -0000 1.31 --- calclib.q 16 Nov 2007 08:08:31 -0000 1.32 *************** *** 183,200 **** started, false otherwise) when the tread is kicked off. ! The task_input semaphore may also yield a triple (S,INIT,'X) to indicate ! that the task button itself was updated while the task is still running. ! This happens when a triggered update of the button is caused by some ! requisite cells of the task button formula changing values. In such a case, ! rather than reexecuting the taskbutton function and restarting the task ! from scratch, the button's new parameters are sent via the semaphore, ! including the new thread expression which is transmitted in quoted form to ! prevent premature evaluation. Again, it is completely up to the task how it ! handles such a message; it may completely ignore it, or it may just ! reexecute the taskbutton function with the new parameters (unquoting the ! thread expression) to replace itself with the new task (to support this, ! the taskbutton function, unlike the other GUI elements, may also be ! executed asynchronously). Alternatively, the task may also cannibalize the ! given data and update its own internal state accordingly. At any time, the background task can also send values back to the hosting --- 183,202 ---- started, false otherwise) when the tread is kicked off. ! The task_input semaphore may also yield a quoted taskbutton call of the ! form '(taskbutton (S,INIT) X) to indicate that the task button itself was ! updated while the task is still running. This happens when a triggered ! update of the button is caused by some requisite cells of the task button ! formula changing values. In such a case, rather than reexecuting the ! taskbutton function and restarting the task from scratch, the taskbutton ! expression with the new parameters are sent via the semaphore. Again, it is ! completely up to the task how it handles such a message; it may completely ! ignore it, or it may just evaluate the (unquoted) taskbutton call to ! replace itself with the new task (to support this, the taskbutton function, ! unlike the other GUI elements, may also be executed asynchronously). ! Alternatively, the task may also extract the needed data from the quoted ! taskbutton call and update its own internal state accordingly. To help with ! this, we provide the task_params special form which, when applied to the ! quoted expression '(taskbutton (S,INIT) (F X1 ... Xn)), where F X1 ... Xn ! is the new task expression, returns the parameter tuple (S,INIT,X1,...,Xn). At any time, the background task can also send values back to the hosting *************** *** 214,223 **** button is, the user can always check whether the task associated with the button is currently up and running by taking a look at the arrow symbol ! shown on the button. If the task is still executing, the arrow symbol will ! be "lit" in green, otherwise it will be greyed out. Also note that in the latter case, if the thread has exited when the user starts it by pressing the button, the task will be restarted automatically. */ ! public special taskbutton ~ARGS X; public task_input, task_index, task_row, task_column; --- 216,226 ---- button is, the user can always check whether the task associated with the button is currently up and running by taking a look at the arrow symbol ! shown on the button. If the task is currently executing (even if it hasn't ! been "started" by pushing the button down yet), the arrow symbol will be ! "lit" in green, otherwise it will be greyed out. Also note that in the latter case, if the thread has exited when the user starts it by pressing the button, the task will be restarted automatically. */ ! public special taskbutton ~ARGS X, task_params X; public task_input, task_index, task_row, task_column; *************** *** 467,470 **** --- 470,485 ---- var YYTASKS = ref emptyhdict, YYSEM = ref emptyhdict; + special task_expr_params ~Xs X; + + task_params '(taskbutton (S,INIT) X) + = (S,INIT|tuple ARGS) + where (S,INIT) = catch () (S,INIT), + ARGS:List = catch () (task_expr_params [] 'X); + + task_expr_params Xs '(F X) + = task_expr_params [X|Xs] 'F; + task_expr_params Xs _ + = Xs otherwise; + task_input = SEM where (I,J,SEM) = get YYSEM!thread_no this_thread; *************** *** 616,620 **** where (H,SEM,'_) = get YYTASKS!(I,J): // task is alive and kicking, update it with the new data ! = post SEM (S,INIT,subst 'X) || INIT if isthread H and then active H; // zombie: kill it, then restart --- 631,636 ---- where (H,SEM,'_) = get YYTASKS!(I,J): // task is alive and kicking, update it with the new data ! = post SEM '(taskbutton (S,INIT) X) || INIT ! where 'X = subst 'X if isthread H and then active H; // zombie: kill it, then restart |