• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Session object in concurrent threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Session object in concurrent threads


  • Subject: Re: Session object in concurrent threads
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 7 Dec 2009 14:07:44 -0800


On Dec 7, 2009, at 2:03 PM, Guido Neitzer wrote:

On 7. Dec. 2009, at 13:39 , Joe Kramer wrote:

I was hoping someone could give me some pointers on how to access a session from concurrent threads.

You don't. This is asking for trouble.

Specifically, you will grow hair on your palms and then go blind. Listen carefully to Guido's advice. You don't want to do what you think you want to do.


Also see WOLongResponsePage and ERXWOLongResponsePage and ERXLongResponse (the last two in Wonder).

Chuck


I am very new to concurrency, so please forgive me for being naive. I have a thread that runs some shell scripts and I wanted the user to still have a responsive UI while the processing is happening in the background. But in the processing I need access to the session object.

Why would you need that? You can pass all information at the beginning of the thread. And don't pass EOs, pass global ids. Never share EOs, editingContexts, or sessions around! Never pass mutable objects without copying them for thread usage. Don't use static variables in utilities. Work with instances or make your code either synchronized or re-entrant.


This is a quite painful subject and it can bite you pretty badly if you get it wrong (which you most certainly will, as everybody who started out on that). So keep it as simple as possible and follow the basic rules:

- no EO crosses thread boundaries
- no session access outside request-response loop (meaning, from multiple threads)
- pass in information, don't reach out for it
- work on copies of the data or immutable objects (remember a container might be immutable but the objects inside might not be)


Any help on this would be greatly appreciated.

Really, you don't want to get into that! Pass to the thread all information it needs to know and use the thread hooks for state information. Use concurrent request handling to keep the UI response if you want, but if you're forking a thread, that isn't even absolutely necessary (though recommended).


cug

--
http://www.event-s.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

-- Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects








_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Session object in concurrent threads
      • From: Guido Neitzer <email@hidden>
    • Re: Session object in concurrent threads
      • From: Joe Kramer <email@hidden>
References: 
 >Session object in concurrent threads (From: Joe Kramer <email@hidden>)
 >Re: Session object in concurrent threads (From: Guido Neitzer <email@hidden>)

  • Prev by Date: Re: All In One Installer broken
  • Next by Date: Re: All In One Installer broken
  • Previous by thread: Re: Session object in concurrent threads
  • Next by thread: Re: Session object in concurrent threads
  • Index(es):
    • Date
    • Thread