Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow calls to clojure proxy

Tags:

clojure

I have an application in clojure making heavy use of a Java framework called Vaadin. Vaadin uses several callbacks using the Java "proxy" feature of clojure. However, every time a proxy is called in a clojure function there is a significant delay (100s of milliseconds sometimes). Is there any way I can speed this up?

like image 346
yazz.com Avatar asked Jan 01 '26 01:01

yazz.com


1 Answers

My understanding is that the new reify macro is faster than proxy. You can use it if you only need to implement a single interface.

For example, if you need to implement a java.awt.event.ActionListener you can use code like the following:

(import 'java.awt.event.ActionListener 'javax.swing.JButton)
(let [a-button (JButton. "Click Me")]
  (.addActionListener a-button
    (reify ActionListener
      (actionPerformed [this ev] (comment do something interesting)))))
like image 75
Ralph Avatar answered Jan 03 '26 14:01

Ralph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!