• 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: EC locking (headless and threads)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EC locking (headless and threads)


  • Subject: Re: EC locking (headless and threads)
  • From: Kieran Kelleher <email@hidden>
  • Date: Fri, 10 Feb 2012 12:22:02 -0500

Also if you use ERXExecutorService to execute any Plain Old Java Callable (or Runnable), your editing contexts will be auto unlocked by safety-net unlocker at the end of execution if you haven't done so ....... however it is highly recommend that you follow the ec lock/try/finally/unlock pattern in in your Callable.call() or Runnable.run() methods anyway which will be better for long running tasks, recycling ec's if needed, etc. it doesn't hurt.

	EOEditingContext ec = ERXEC.newEditingContext();
        ec.lock();
        try {
           ........
        } finally {
            ec.unlock();
        }

And yeah, do what Ramsey said .... save yourself time figuring out concurrency management of EC's, etc. by watching the WOWODC presentation from 2011. There is a bunch of stuff related to this in Wonder to make life in the background easy and totally painless for you and that WOWODC session explains it's usage.


On Feb 10, 2012, at 11:34 AM, Ramsey Gurley wrote:

> If you use ERXRunnable, then you still get autolocking.  Just don't try to pass an existing EC or EOs to a background thread.  Pass EOs by global id and create the EC on the thread.
>
> See also Kieran's most recent WOWODC presentation on ERXExecutor stuff and background thread processing.
>
> Ramsey
>
> On Feb 10, 2012, at 9:30 AM, Michael Gargano wrote:
>
>> Hi everyone,
>>
>> 	I just want to get clarification on something before I get myself into trouble later.  If I have a headless WO app (or potential just a spawned worker thread), and I'm using ERXEC, I need to manually lock and unlock the context, correct?  I'm assuming that ERXEC does the autolock/autounlock in the RR loop, which I won't have in this situation.
>>
>> Thanks.
>> -Mike
>>
>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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


 _______________________________________________
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: EC locking (headless and threads)
      • From: Giles Palmer <email@hidden>
References: 
 >EC locking (headless and threads) (From: Michael Gargano <email@hidden>)
 >Re: EC locking (headless and threads) (From: Ramsey Gurley <email@hidden>)

  • Prev by Date: d2w targeting the Query page
  • Next by Date: Re: d2w targeting the Query page
  • Previous by thread: Re: EC locking (headless and threads)
  • Next by thread: Re: EC locking (headless and threads)
  • Index(es):
    • Date
    • Thread