Re: Re: Swing Threading in SimpleORM

Noel Grandin <[email protected]> Mon, 13 Jun 2011 14:20:23 +0200
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
--------------090509080703050101010901
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


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] <mailto:[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] <mailto:[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] <mailto:[email protected]>       Mobile: +61 4 4838 8874
>     <tel:%2B61%204%204838%208874>
>     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] <mailto:[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



--------------090509080703050101010901
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit





<head>

<style type="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 
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none; 
       }

       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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">





    <font face="Tahoma"><br>
      If I created a patch to turn the only-one-thread-checking off,
      would 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 tries to access an session while the lock is held.<br>
      <br>
      Regards, Noel Grandin.<br>
    </font><br>
    anthony berglas wrote:
    <blockquote
      cite="mid:[email protected]"
      type="cite">
      <span style="display: none;">&nbsp;</span>
      
          <div id="ygrp-text">
            <p><br>
              <br>
            </p>
            <div class="gmail_quote">On Mon, Jun 13, 2011 at 3:45 PM,
              anthony berglas <span dir="ltr">&lt;<a
                  moz-do-not-send="true"
                  href="mailto:[email protected]">[email protected]</a>&gt;</span>
              wrote:<br>
              <blockquote class="gmail_quote" style="border-left: 1px
                solid rgb(204, 204, 204);">
                <div>I have never liked Swing's over complex threading.</div>
                <div><br>
                </div>
                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.
                <div>
                  <br>
                </div>
                <div>One option is to open and close the session on each
                  thread. &nbsp;The overhead is small, and it would be
                  cleaner.</div>
                <div><br>
                </div>
                <div>Regards,</div>
                <div><br>
                </div>
                <div>Anthony</div>
                <div>
                  <div class="h5">
                    <div><br>
                    </div>
                    <div class="gmail_quote">
                      On Wed, Jun 8, 2011 at 6:05 PM, James Pickering <span
                        dir="ltr">&lt;<a moz-do-not-send="true"
                          href="mailto:[email protected]"
                          target="_blank">[email protected]</a>&gt;</span>
                      wrote:<br>
                      <blockquote class="gmail_quote"
                        style="border-left: 1px solid rgb(204, 204,
                        204);">
                        <div>
                          <div style="font-family: sans-serif;
                            font-size: 16px;">Hi,<br>
                            <br>
                            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.<br>
                            <br>
                            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.<br>
                            <br>
                            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.<br>
                            <br>
                            Any thought?<br>
                            <br>
                            Thanks, James</div>
                        </div>
                      </blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <br>
                  </div>
                </div>
                <font color="#888888">-- <br>
                  <p>
                  </p>
                  <p>Dr Anthony Berglas, <a moz-do-not-send="true"
                      href="mailto:[email protected]" target="_blank">[email protected]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Mobile: <a moz-do-not-send="true"
                      href="tel:%2B61%204%204838%208874"
                      value="+61448388874" target="_blank">+61 4 4838
                      8874</a><br>
                    Just because it is possible to push twigs along the
                    ground with ones nose<br>
                    does not necessarily mean that that is the best way
                    to collect firewood.</p>
                  <br>
                </font></blockquote>
            </div>
            <br>
            <br clear="all">
            <br>
            -- <br>
            <p>
            </p>
            <p>Dr Anthony Berglas, <a moz-do-not-send="true"
                href="mailto:[email protected]" target="_blank">[email protected]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Mobile: +61 4 4838 8874<br>
              Just because it is possible to push twigs along the ground
              with ones nose<br>
              does not necessarily mean that that is the best way to
              collect firewood.</p>
            <br>
          </div>
          
      
      <!-- end group email -->
    </blockquote>
  <br><br><br><hr><font size="-2" color=808080>Disclaimer: <a href="http://www.peralex.com/disclaimer.html">http://www.peralex.com/disclaimer.html</a><br><br>





<!-- |**|begin egp html banner|**| -->

<br>

    
    
<br>

<!-- |**|end egp html banner|**| -->


<div width="1" style="color: white; clear: both;"/>__._,_.___</div>

<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src="http://geo.yahoo.com/serv?s=97476590/grpId=7360226/grpspId=1705006905/msgId=2032/stime=1307967636" width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->

    
<!-- |**|begin egp html banner|**| -->

<br>
      <div style="font-family: verdana; font-size: 77%; border-top: 1px solid #666; padding: 5px 0;" >
      Your email settings: Individual Email|Traditional <br>
      <a href="http://groups.yahoo.com/group/SimpleORM/join;_ylc=X3oDMTJmcTY0amZiBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzMDc5Njc2MzY-">Change settings via the Web</a> (Yahoo! ID required) <br>
      Change settings via email: <a href="mailto:[email protected]?subject=Email Delivery: Digest">Switch delivery to Daily Digest</a> | <a href = "mailto:[email protected]?subject=Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br>
           <a href="http://groups.yahoo.com/group/SimpleORM;_ylc=X3oDMTJkbGUwNjZnBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA2hwZgRzdGltZQMxMzA3OTY3NjM2">
        Visit Your Group 
      </a> |
      <a href="http://docs.yahoo.com/info/terms/">
        Yahoo! Groups Terms of Use
      </a> |
      <a href="mailto:[email protected]?subject=Unsubscribe">
       Unsubscribe 
      </a> 
 <br>
    </div>
  <br>

<!-- |**|end egp html banner|**| -->


<div style="color: white; clear: both;"/>__,_._,___</div>
</body>
</html>

--------------090509080703050101010901--