sleyzerzon / soar

Automatically exported from code.google.com/p/soar
1 stars 0 forks source link

add simplified threading model #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by voigtjr@gmail.com on 23 Jul 2009 at 4:34

GoogleCodeExporter commented 8 years ago
Description From Bob Marinier 2007-05-26 12:00:16 (-) [reply]
Currently, SML is set up to maximize performance.  As such, it assumes that
various calls are executed from the correct threads.  If this isn't done, bad
things happen.  In practice, setting things up correctly turns out to be very
challenging.  Thus, it was suggested that a mode or set of calls that took care
of this automatically be introduced.  Doug estimates that this will cause a
factor 2 slowdown, but in many cases, performance is not an issue. Dave Ray
pointed specifically to these kinds of problems as slowing down development of
the Soar IDE.

For compatibility and performance, existing functions and behavior can stay
exactly the same.  But we can possibly introduce new calls, e.g.
ExecuteCommandLineTS (TS=Thread Safe) for those cases where we just want to
make something work.  Or maybe there can just be a call or flag that sets a
mode that affects all calls.
------- Comment #1 From Dave Ray 2007-05-26 13:48:55 (-) [reply] -------
One possibility is to push the functionality provided by DocumentThread2 in the
debugger down into the base API so it's available for all languages without
reducing the level of control/performance provided by the existing API.
Something like this (using Java syntax here, but would be implement in C++):

   Kernel kernel = Kernel.CreateKernelInNewThread();
   KernelThreadManager thread = kernel.CreateThreadManager();

   // ... create agents and stuff ...

   // Execute a command and wait for the result.
   String s1 = thread.ExecuteCommandLineSync(agent, "print s1");

   // Execute a command asynchronously
   thread.ExecuteCommandLineAsync(agent, "run");

   // Execute a command implemented by the caller in the kernel thread
   thread.ExecuteCommandAsync(new KernelThreadCommand() { ... impl ...});

   ... etc ...

A few things:
* "KernelThreadManager" is a pretty lame name.
* This pattern is pretty typical in UI systems that have a dedicated UI thread
so it shouldn't be totally unfamiliar to programmers:
** In Swing, SwingUtilities.invokeLater(Runnable)
** In Eclipse, Display.asyncExec(Runnable)

Original comment by voigtjr@gmail.com on 23 Jul 2009 at 5:23

GoogleCodeExporter commented 8 years ago

Original comment by voigtjr@gmail.com on 23 Jul 2009 at 5:29

GoogleCodeExporter commented 8 years ago

Original comment by voigtjr@gmail.com on 23 Feb 2010 at 7:43