[GRASS5] Tk <-> C

Glynn Clements glynn.clements at virgin.net
Tue Sep 24 23:55:38 EDT 2002


Radim Blazek wrote:

> can anybody tell me how to start C function by click on Tk
> button so that Tk interface doesn't wait until C function
> ends. Like "DRAW" button in nviz. I cannot find the trick.
> 
> I have already tracked the chain in nviz (see below) but
> I cannot find how is that done. My application always wait 
> for C function end.

[snip]

> surf_draw_all (Nv_data *dc, Tcl_Interp *interp) {

surf_draw_all()
calls GS_draw_surf()
which calls gsd_surf()
which calls gsd_surf_map()
which calls GS_check_cancel() at the start of every row
which calls (*Cxl_func)
which is set by GS_set_cxl_func()
which is called by Nset_cancel_func_cmd()
which is called by the Tcl command Nset_cancel_func
which is called at the top-level of nviz2.2_script
with argument "update".

IOW, the OGSF drawing functions repeatedly call back to the "update"
function, which probably explains why the interface doesn't freeze.

However, unless the authors of both NVIZ and OGSF have been very
careful, attempting to actually use the interface while drawing is in
progress may have undesirable consequences.

The difficulty in writing "multi-threaded" code isn't in implementing
the multi-threading, but ensuring that the code allows for the
consequences.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list