def doesn't create a thread-local binding, it creates a var within a particular namespace -- the binding form is what established the thread-local binding. So, when used on the AWT/Swing thread,
(binding [*my_environment* (new_environment)] ...) will execute the body of the binding form with the *my_environment* var bound to the value of (new_environment). - Chas On Feb 11, 2009, at 8:40 PM, CuppoJava wrote: > > Hi, > I just wrote a library that creates an un-initialized global variable, > and requires the user to create his own thread-local binding in order > to run it. > > eg. > (def *my_environment*) > ... > > and the user would use it like so: > (binding [*my_environment* (new_environment)] > (start_engine_thread)) > > And this works wonderfully for my custom engine. > > But now I wrote a engine using Swing. And I don't have control over > when the Swing thread is started. So there's no way for me to create a > thread-local binding to use my library. > > eg. I can't do this: > (binding [*my_environment* (new_environment)] > (start_swing_event_thread) > (.setVisible (new_engine))) > > So is there anyway for me to push a thread-local binding, when the > thread has already been started? > > Or is there a clean workaround for this problem? Instead of having to > resort to passing *my_environment* around through function parameters. > > Thanks a lot > -Patrick > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---