Re: Re: Swing Threading in SimpleORM
anthony berglas <[email protected]> Sat, 18 Jun 2011 17:50:14 +1000
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
--001636498cff033c6404a5f7c350 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Yes, I'm pretty sure we did this for SConnectionEJB. The thread checking is not unimportant, and could trap some very insidious bugs. So I would prefer to explicitly specify to SimpleOrm when threads change rather than just turn it off. Anthony On Thu, Jun 16, 2011 at 7:30 PM, Franck Routier <[email protected]>w= rote: > Hi, > > am I wrong, or is it the same kind of problems that were once worked > around by SConnectionEJB ? > > Maybe we could have a pluggable way of checking thread (or transaction > or wathever) safety ? > In fact right now, SSessionJdbc is in fact two-sided. It has a static > part (to open a session and manage thread safety) that acts as a > manager, and a non static part that is the real session. > > Maybe they should be separated ? > > > Franck > > > > > Le lundi 13 juin 2011 =E0 14:20 +0200, Noel Grandin a =E9crit : > > > > > > If I created a patch to turn the only-one-thread-checking off, would > > that be acceptable? > > > > Or maybe I could create a patch that has two checking modes > > (mode a) the normal only-one-thread checking > > (mode b) create a per-session lock and throw an exception if anyone > > tries to access an session while the lock is held. > > > > Regards, Noel Grandin. > > > > anthony berglas wrote: > > > > > > > > > > > > > > > On Mon, Jun 13, 2011 at 3:45 PM, anthony berglas > > > <[email protected]> wrote: > > > I have never liked Swing's over complex threading. > > > > > > > > > Your solution sounds OK (maybe we should use protected > > > rather than package) but I would be concerned that if you > > > end up with more than one swing thread active at a time bad > > > things will happen. > > > > > > > > > One option is to open and close the session on each thread. > > > The overhead is small, and it would be cleaner. > > > > > > > > > Regards, > > > > > > > > > Anthony > > > > > > > > > On Wed, Jun 8, 2011 at 6:05 PM, James Pickering > > > <[email protected]> wrote: > > > Hi, > > > > > > I'm having some difficulty getting Swing and > > > SimpleORM to play nice. I've got a workaround, but > > > I'm sure there's a better way. > > > > > > My app uses Swing, and only ever calls SimpleORM > > > from the Swing Event Dispatch Thread. The difficulty > > > is, there's no such thing as "the" Event Dispatch > > > Thread; under some circumstances, Swing recycles it > > > and creates a new one (they're not common > > > circumstances, but I hit them in unit testing). This > > > doesn't sit well with SimpleORM's thread affinity. > > > > > > I've worked around it by creating a subclass of > > > SSessionJdbc, where checkThread() checks it's being > > > run from the EDT, rather than worrying about its > > > preferred thread. With checkThread() being > > > package-private though, it's not an ideal solution. > > > > > > Any thought? > > > > > > Thanks, James > > > > > > > > > > > > > > > -- > > > > > > > > > Dr Anthony Berglas, [email protected] Mobile: +61 4 > > > 4838 8874 > > > Just because it is possible to push twigs along the ground > > > with ones nose > > > does not necessarily mean that that is the best way to > > > collect firewood. > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 > > > 8874 > > > Just because it is possible to push twigs along the ground with ones > > > nose > > > does not necessarily mean that that is the best way to collect > > > firewood. > > > > > > > > > > > > > > > > > > > ______________________________________________________________________ > > Disclaimer: http://www.peralex.com/disclaimer.html > > > > > > > > > >=20 > > > --=20 Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 8874 Just because it is possible to push twigs along the ground with ones nose does not necessarily mean that that is the best way to collect firewood. --001636498cff033c6404a5f7c350 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable <head> <style type=3D"text/css"> <!-- /* start of attachment style */ .ygrp-photo-title{ clear: both; font-size: smaller; height: 15px; overflow: hidden; text-align: center; width: 75px; } div.ygrp-photo{ background-position: center; background-repeat: no-repeat; background-color: white; border: 1px solid black; height: 62px; width: 62px; } div.photo-title=20 a, div.photo-title a:active, div.photo-title a:hover, div.photo-title a:visited { text-decoration: none;=20 } div.attach-table div.attach-row { clear: both; } div.attach-table div.attach-row div { float: left; /* margin: 2px;*/ } p { clear: both; padding: 15px 0 3px 0; overflow: hidden; } div.ygrp-file { width: 30px; valign: middle; } div.attach-table div.attach-row div div a { text-decoration: none; } div.attach-table div.attach-row div div span { font-weight: normal; } div.ygrp-file-title { font-weight: bold; } /* end of attachment style */ --> </style> </head> <html> <head> <style type=3D"text/css"> <!-- #ygrp-mkp { border: 1px solid #d8d8d8; font-family: Arial; margin: 10px 0; padding: 0 10px; } #ygrp-mkp hr { border: 1px solid #d8d8d8; } #ygrp-mkp #hd { color: #628c2a; font-size: 85%; font-weight: 700; line-height: 122%; margin: 10px 0; } #ygrp-mkp #ads { margin-bottom: 10px; } #ygrp-mkp .ad { padding: 0 0; } #ygrp-mkp .ad p { margin: 0; } #ygrp-mkp .ad a { color: #0000ff; text-decoration: none; } --> </style> </head> <body> Yes, I'm pretty sure we did this for SConnectionEJB.<div><br></div><div= >The thread checking is not unimportant, and could trap some very insidious= bugs. =A0So I would prefer to explicitly specify to SimpleOrm when threads= change rather than just turn it off.</div> <div><br></div><div>Anthony<br><br><div class=3D"gmail_quote">On Thu, Jun 1= 6, 2011 at 7:30 PM, Franck Routier <span dir=3D"ltr"><<a href=3D"mailto:= [email protected]">[email protected]</a>></span> wrote:<br= > <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;"> Hi,<br> <br> am I wrong, or is it the same kind of problems that were once worked<br> around by SConnectionEJB ?<br> <br> Maybe we could have a pluggable way of checking thread (or transaction<br> or wathever) safety ?<br> In fact right now, SSessionJdbc is in fact two-sided. It has a static<br> part (to open a session and manage thread safety) that acts as a<br> manager, and a non static part that is the real session.<br> <br> Maybe they should be separated ?<br> <br> <br> Franck<br> <br> <br> <br> <br> Le lundi 13 juin 2011 =E0 14:20 +0200, Noel Grandin a =E9crit :<br> <div><div></div><div class=3D"h5">><br> ><br> > If I created a patch to turn the only-one-thread-checking off, would<b= r> > that be acceptable?<br> ><br> > Or maybe I could create a patch that has two checking modes<br> > (mode a) the normal only-one-thread checking<br> > (mode b) create a per-session lock and throw an exception if anyone<br= > > tries to access an session while the lock is held.<br> ><br> > Regards, Noel Grandin.<br> ><br> > anthony berglas wrote:<br> > ><br> > ><br> > ><br> > ><br> > > On Mon, Jun 13, 2011 at 3:45 PM, anthony berglas<br> > > <<a href=3D"mailto:[email protected]">[email protected]</a= >> wrote:<br> > > =A0 =A0 =A0 =A0 I have never liked Swing's over complex threa= ding.<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 Your solution sounds OK (maybe we should use prot= ected<br> > > =A0 =A0 =A0 =A0 rather than package) but I would be concerned tha= t if you<br> > > =A0 =A0 =A0 =A0 end up with more than one swing thread active at = a time bad<br> > > =A0 =A0 =A0 =A0 things will happen.<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 One option is to open and close the session on ea= ch thread.<br> > > =A0 =A0 =A0 =A0 =A0The overhead is small, and it would be cleaner= .<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 Regards,<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 Anthony<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 On Wed, Jun 8, 2011 at 6:05 PM, James Pickering<b= r> > > =A0 =A0 =A0 =A0 <<a href=3D"mailto:[email protected]">jame= [email protected]</a>> wrote:<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Hi,<br> > ><br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I'm having some difficulty ge= tting Swing and<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SimpleORM to play nice. I've = got a workaround, but<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I'm sure there's a better= way.<br> > ><br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 My app uses Swing, and only ever = calls SimpleORM<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 from the Swing Event Dispatch Thr= ead. The difficulty<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 is, there's no such thing as = "the" Event Dispatch<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Thread; under some circumstances,= Swing recycles it<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 and creates a new one (they'r= e not common<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 circumstances, but I hit them in = unit testing). This<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 doesn't sit well with SimpleO= RM's thread affinity.<br> > ><br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I've worked around it by crea= ting a subclass of<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SSessionJdbc, where checkThread()= checks it's being<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 run from the EDT, rather than wor= rying about its<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 preferred thread. With checkThrea= d() being<br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 package-private though, it's = not an ideal solution.<br> > ><br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Any thought?<br> > ><br> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Thanks, James<br> > ><br> > ><br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 --<br> > ><br> > ><br> > > =A0 =A0 =A0 =A0 Dr Anthony Berglas, <a href=3D"mailto:anthony@ber= glas.org">[email protected]</a> =A0 =A0 =A0 Mobile: +61 4<br> > > =A0 =A0 =A0 =A0 4838 8874<br> > > =A0 =A0 =A0 =A0 Just because it is possible to push twigs along t= he ground<br> > > =A0 =A0 =A0 =A0 with ones nose<br> > > =A0 =A0 =A0 =A0 does not necessarily mean that that is the best w= ay to<br> > > =A0 =A0 =A0 =A0 collect firewood.<br> > ><br> > ><br> > ><br> > ><br> > ><br> > > --<br> > ><br> > ><br> > > Dr Anthony Berglas, <a href=3D"mailto:[email protected]">anthon= [email protected]</a> =A0 =A0 =A0 Mobile: +61 4 4838<br> > > 8874<br> > > Just because it is possible to push twigs along the ground with o= nes<br> > > nose<br> > > does not necessarily mean that that is the best way to collect<br= > > > firewood.<br> > ><br> > ><br> > ><br> ><br> ><br> ><br> ><br> </div></div>> __________________________________________________________= ____________<br> <div class=3D"im">> Disclaimer: <a href=3D"http://www.peralex.com/discla= imer.html" target=3D"_blank">http://www.peralex.com/disclaimer.html</a><br> ><br> ><br> ><br> ><br> </div><div class=3D"im">> <br> <br> <br> </div></div></blockquote></div><br><br clear=3D"all"><br>-- <br><p> </p><p>Dr Anthony Berglas, <a href=3D"mailto:[email protected]" target=3D= "_blank">[email protected]</a>=A0=A0=A0=A0=A0=A0 Mobile: +61 4 4838 8874<= br> Just because it is possible to push twigs along the ground with ones nose<b= r> does not necessarily mean that that is the best way to collect firewood.</p= ><br> </div> <!-- |**|begin egp html banner|**| --> <br> =20=20=20=20 =20=20=20=20 <br> <!-- |**|end egp html banner|**| --> <div width=3D"1" style=3D"color: white; clear: both;"/>__._,_.___</div> <!-- Start Recommendations --> <!-- End Recommendations --> <!-- |**|begin egp html banner|**| --> <img src=3D"http://geo.yahoo.com/serv?s=3D97476590/grpId=3D7360226/grpspI= d=3D1705006905/msgId=3D2034/stime=3D1308383456" width=3D"1" height=3D"1"> <= br> <!-- |**|end egp html banner|**| --> =20=20 <!-- |**|begin egp html banner|**| --> <br> <div style=3D"font-family: verdana; font-size: 77%; border-top: 1px s= olid #666; padding: 5px 0;" > Your email settings: Individual Email|Traditional <br> <a href=3D"http://groups.yahoo.com/group/SimpleORM/join;_ylc=3DX3oDMT= JmbXFwZThtBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY= wNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzMDgzODM0NTY-">Change settings via the Web</a= > (Yahoo! ID required) <br> Change settings via email: <a href=3D"mailto:SimpleORM-digest@yahoogr= oups.com?subject=3DEmail Delivery: Digest">Switch delivery to Daily Digest<= /a> | <a href =3D "mailto:[email protected]?subject=3D= Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br> <a href=3D"http://groups.yahoo.com/group/SimpleORM;_ylc=3DX3oDMT= JkNzJhaHBjBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY= wNmdHIEc2xrA2hwZgRzdGltZQMxMzA4MzgzNDU2"> Visit Your Group=20 </a> | <a href=3D"http://docs.yahoo.com/info/terms/"> Yahoo! Groups Terms of Use </a> | <a href=3D"mailto:[email protected]?subject=3DUns= ubscribe"> Unsubscribe=20 </a>=20 <br> </div> <br> <!-- |**|end egp html banner|**| --> <div style=3D"color: white; clear: both;"/>__,_._,___</div> </body> </html> --001636498cff033c6404a5f7c350--