Launching a standard C "Window Events Loop" thread.
Yves Jaradin
yjaradin at info.ucl.ac.be
Wed Feb 21 16:44:34 CET 2007
Julien ERES wrote:
> Hi,
>
> I have to make an Human-Machine Interface in C++/OpenGL to monitor a
> system made in Oz.
> I have already coded the C++ part but i'm newbie in Oz programming, i
> don't have to code lot of Oz but i must do the interfacing part.
> I already understood the basics of interfacing Oz and C/C++
> (OZ_C_proc_interface) but i don't know what is the best method to
> launch my main loop (C++ part).
> For the moment i export a function like this :
> OZ_BI_define(cihm_launch, 0, 0)
> {
> pthread_t thread;
> int iret = pthread_create(&thread, NULL, loop, (void*) NULL);
> } OZ_BI_end
> The problem is that Oz start to call other C functions before this
> thread is really launched.
> How to synchronize ?
>
> I think it should be better to launch the thread in Oz, have it a
> method to do this ?
> (Maybe using OZ_makeRunnableThread. How to use it ?)
>
> I'm interested to derivate a class from OZ_Extension, maybe it could
> solve this problem and more,
> in fact i do it, but i still continue to use OZ_C_proc_interface too.
> I'm not sure to unterstand the purpose of OZ_Extension...
>
> ||Please can you help me, with detailled Oz codes.
> I already read "Reference Manuals - Interfacing to C and C++"
> I need more detailed examples.
> (I also serched in MOGUL for this kind of interfacing but i only find
> "classical" C export)
>
> That's all for now,
> Thank You,
> Julien.
>
>------------------------------------------------------------------------
>
>_________________________________________________________________________________
>mozart-users mailing list mozart-users at mozart-oz.org
>http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
Right now, the emulator won't work well with pthreads. Some people are
working on this issue but something usable has yet to appear.
The solutions you have are to run the event loop in Oz (if all the loop
does is polling event and handling them it might be an option) or to run
the event loop in a separate application and use some IPC to connect it
to the emulator. This last solution is what is used with the tk interface.
OZ_makeRunnableThread won't help you as everything about threads in the
emulator is about Oz threads which can only be used to execute Oz code.
OZ_Extension is a class that can be extended to create new datatypes in
Oz. I'm not sure how this can be of any help in this regard.
The IPC solution is typically done with TCP sockets.You might find some
XML support in Mogul if you don't want to serialize all your messages to
raw bytes by hand.
Cheers,
Yves
More information about the mozart-users
mailing list