SafeVariable

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

SafeVariable

nabblee
GParallelizer had something called SafeVariable.  What is the GPars equivalent?

Thank you,
Lee
Reply | Threaded
Open this post in threaded view
|

Re: SafeVariable

nabblee
I should have been clearer.  I'm looking for the easiest way to use thread-safe maps and lists.  It doesn't have to come from GPars.  I'm open to suggestions.

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: SafeVariable

Bob Brown
Well, plain old Java has:

http://docs.oracle.com/javase/tutorial/essential/concurrency/collections.htm
l

and:

http://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.h
tml

Groovy has collection conveniences like:

<a href="http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#asSynchronized%28%2">http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#asSynchronized%28%2
9

Take a look at:

http://www.slideshare.net/paulk_asert/groovy-and-concurrency

HTH

BOB

> -----Original Message-----
> From: nabblee [mailto:[hidden email]]
> Sent: Thursday, 10 April 2014 10:01 AM
> To: [hidden email]
> Subject: [gpars-user] Re: SafeVariable
>
> I should have been clearer.  I'm looking for the easiest way to use
thread-safe
> maps and lists.  It doesn't have to come from GPars.  I'm open to
suggestions.
>
> Thank you!
>
>
>
> --
> View this message in context: http://gpars-user-mailing-
> list.19372.n3.nabble.com/SafeVariable-tp4024957p4024958.html
> Sent from the GPars - user mailing list mailing list archive at
Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: SafeVariable

Vaclav
Administrator
You might be looking for Agent or a DataflowVariable, I believe.

Vaclav



On Thu, Apr 10, 2014 at 2:41 AM, Bob Brown <[hidden email]> wrote:
Well, plain old Java has:

http://docs.oracle.com/javase/tutorial/essential/concurrency/collections.htm
l

and:

<a href="http://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.h tml" target="_blank">http://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.h
tml

Groovy has collection conveniences like:

<a href="http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#asSynchronized%28%2" target="_blank">http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#asSynchronized%28%2
9

Take a look at:

http://www.slideshare.net/paulk_asert/groovy-and-concurrency

HTH

BOB

> -----Original Message-----
> From: nabblee [mailto:[hidden email]]
> Sent: Thursday, 10 April 2014 10:01 AM
> To: [hidden email]
> Subject: [gpars-user] Re: SafeVariable
>
> I should have been clearer.  I'm looking for the easiest way to use
thread-safe
> maps and lists.  It doesn't have to come from GPars.  I'm open to
suggestions.
>
> Thank you!
>
>
>
> --
> View this message in context: http://gpars-user-mailing-
> list.19372.n3.nabble.com/SafeVariable-tp4024957p4024958.html
> Sent from the GPars - user mailing list mailing list archive at
Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
E-mail: [hidden email]
Blog: http://www.jroller.com/vaclav
Linkedin page: http://www.linkedin.com/in/vaclavpech
Reply | Threaded
Open this post in threaded view
|

Re: SafeVariable

Russel Winder-3
In reply to this post by nabblee
On Wed, 2014-04-09 at 17:00 -0700, nabblee wrote:
> I should have been clearer.  I'm looking for the easiest way to use
> thread-safe maps and lists.  It doesn't have to come from GPars.  I'm open
> to suggestions.

I would suggest this is likely a Java Platform thing rather than GPars
thing. Possible approaches I can think of:

1. Use the Collections wrappers to create synchronized data structures,
i.e. make them thread safe.

2. Use ConcurrentHashMap and it's colleagues.

3. Wrap the data structures with a GPars agent.

4. Use a GPars DataflowVariable.

5. Use a Java CompletableFuture.


--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: SafeVariable

nabblee
I appreciate all the suggestions.  I ended up using the @ActiveObject and @ActiveMethod annotations to put my collections under the control of an Actor.  I considered an Agent, but I didn't really like the need to pass in the closures from all over my source, since I really wanted to encapsulate that logic within the Actor class.

Does this seem like a reasonable approach, or is there something I'm misunderstanding?

(I also posted a problem that seems like a bug where I get a VerifyError.)

Thank you for your insights,
Lee