[Gambas-user] Re; Threads ...
Doriano Blengino
doriano.blengino at ...1909...
Thu Feb 5 21:03:41 CET 2009
Gareth Bult ha scritto:
> Hi,
>
> Very basic question .. is there any way to set off a method or procedure in Gambas such that it runs in a thread?
>
> In particular I'm thinking about a Gambas web server where a process might need to retrieve information from a slow storage device or database server, or via a raw network socket, and while it's doing that, I don't want it to block other requests .... ??
>
> tia
> Gareth
>
Uhm... nice question.
Gambas does not support threads, and can not do asynchronous I/O. But
perhaps there is a trick... :->>
Suppose you have to read from a slow device. Let do this job by an
external program (/bin/cat, for example); you then launch this external
program in background, and rely on its events for reading. Use:
exec [...] for read as "exec"
public sub exec_read()
...
The same could hold true about writing to slow devices; if they are true
devices then the kernel should buffer things for you; if it is something
else (a database connection), this trick of external programs could work.
But in the end, I suspect it is a complicated job... if you want several
connections you have to keep trace of every one - not an easy job. And
probably it would be slow (on my home machine EXECs are really slow, I
don't know why).
Regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list