[Ecls-list] Accessing C variables

Dean O'Connor dean.oconnor at ite.com.au
Wed Oct 5 23:31:30 UTC 2005


Hello again,

I have managed to access my C-strings quite well using FFI, thx.

Now I wish to delve into the dark side a little ... multi-threading.
There is basically nothing in the doco regarding this.
I have searched thru this forum archive and found a few hits on this 
topic. Some seem to indicate crossing the windows and lisp threads is 
not possible ??

Can you please give me any more information on the status/stability of 
multi-threaded for windows and linux ?

We have a C++ application that processes trade data. Each trade is 
basically broken down into a map of name/value string pairs (in C++).
We have lisp scripts that will anaylse each trade and call back 
predefined C++ functions with actions to perform.
The two functions F_var and emit_portfolio I have included below give 
you some idea how we access C++ variables and perform actions 
respectively. (prob not the best way :)

The tricky part is that at the moment we only do one trade at a time, 
and this should pose no problem. But we wish to process a number of 
trades concurrently to improve performance.
Each trade will be processed in its own C++ thread. I plan for each C++ 
thread to call the same lisp rule script.
We will add further C++ mutexing around our datastructures used in 
functions below, but I am concerned that this approach is going to work 
at all with what I have read so far !!

Does anyone have any examples of this kind of multithread approach ?
To what extent is ECL threadsafe ?
Any ideas on other approaches, like using Lisp threading solely ??

PS: one side note. When I compile ELCS (from CVS - now version H) with 
multithreading on windows (using MS VC 6), the ecl.exe is not produced, 
only the ecl_min.exe ? Any reason in particular ?


static cl_object F_var(cl_object name)
{
    char *value = g_variableMgr.get((char*)name->string.self);      // 
just get the value of a name matching this string (if any) from our 
local variable map
    if (value)
    {
        cl_object ff_obj = ecl_make_foreign_data(c_string_to_object("(* 
:char)"), strlen(value)+1, value);
        return ff_obj;
    }

    return Cnil;
}

static cl_object emit_portfolio(cl_object name)
{
    // This function is called from lisp script to perform some action 
on C++ datastructures.
    cout << "Emit Portfolio: " << name->string.self << endl;

    return Ct;
}

Thx for any advice ...
cheers
Dean




More information about the ecl-devel mailing list