Giter VIP home page Giter VIP logo

Comments (12)

motlin avatar motlin commented on June 29, 2024

We have these synchronized wrappers, and we have MultiReader* collections like MultiReaderFastList. We don't have any wrappers that use ReadWriteLock AFAIK, but I think it's a good idea to add them. Note that it would have to be an addition, not a change to the synchronized wrappers, because it's a compatibility breaking change in behavior. Specifically, synchronizing on the wrapper itself would no longer work.

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

from eclipse-collections.

donraab avatar donraab commented on June 29, 2024

It looks based on the link above that you would like this on primitive collections, correct?

If you look at the MultiReader collections like MultiReaderFastList, you'll see we made the design decision to throw UnsupportedOperationException in iterator(). There are two methods that allow imperative code to be written safely with a read lock or write lock taken on the collection. They are:

public void withReadLockAndDelegate(Procedure<MutableList<T>> procedure)
public void withWriteLockAndDelegate(Procedure<MutableList<T>> procedure)

I'm a big fan of symmetry, so it would be great to have this style of collection available on the primitive side as well, especially since you have a use case for them. The question I would have is do you need a wrapper for a list that you need a direct pointer to, or can you take the same approach as we did with the MultiReader collections on the object side, where they can be created, but the internal list can never be accessed directly?

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

Please reopen this issue, I am working on a pull request.

from eclipse-collections.

motlin avatar motlin commented on June 29, 2024

Renamed the title to more accurately reflect the work, and reopening.

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

@motlin @donraab
I implemented MultiReaderPrimitiveList. I decided to use wrapper over separate implementation, because it has way less code duplication. foreach works similar way on both versions.

I have a patch ready:
jankotek@5e32442

It passes unit tests, but code generator fails with with exception bellow. I am not sure howto hook new STG templates and files into build script. I tried to read doc, search names etc... But at this point I need your help.

MultiReader STG template is based on synchronized wrapper. Code generation only fails if I changed target file name from:

fileName(primitive) ::= "Synchronized<primitive.name>ListTest"

To:

fileName(primitive) ::= "MultiReader<primitive.name>ListTest"

Maven exception:

  
[INFO] --- eclipse-collections-code-generator-maven-plugin:8.1.0-RC:generate (list) @ unit-tests ---
[INFO] Generating sources to unit-tests
[ERROR] String template run time error while processing [/home/jan/os/eclipse-collections/eclipse-collections-code-generator/target/classes/test/list/mutable/multiReaderPrimitiveListTest.stg]: context [/class /body] 18:86 no such template: /no matching literal
[ERROR] String template run time error while processing [/home/jan/os/eclipse-collections/eclipse-collections-code-generator/target/classes/test/list/mutable/multiReaderPrimitiveListTest.stg]: context [/class /body] 18:86 internal error: java.lang.RuntimeException
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator$LoggingErrorListener.logError(EclipseCollectionsCodeGenerator.java:228)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator$LoggingErrorListener.runTimeError(EclipseCollectionsCodeGenerator.java:240)
        at org.stringtemplate.v4.misc.ErrorManager.runTimeError(ErrorManager.java:133)
        at org.stringtemplate.v4.STGroup.getEmbeddedInstanceOf(STGroup.java:183)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:235)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:742)
        at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:674)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.ST.write(ST.java:427)
        at org.stringtemplate.v4.ST.render(ST.java:497)
        at org.stringtemplate.v4.ST.render(ST.java:491)
        at org.stringtemplate.v4.ST.render(ST.java:487)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator.executeTemplate(EclipseCollectionsCodeGenerator.java:162)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator.generateFiles(EclipseCollectionsCodeGenerator.java:112)
        at org.eclipse.collections.codegenerator.maven.GenerateMojo.execute(GenerateMojo.java:79)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

[ERROR] String template run time error while processing [/home/jan/os/eclipse-collections/eclipse-collections-code-generator/target/classes/test/list/mutable/multiReaderPrimitiveListTest.stg]: context [/class] 1:0 internal error: java.lang.RuntimeException
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator$LoggingErrorListener.logError(EclipseCollectionsCodeGenerator.java:228)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator$LoggingErrorListener.runTimeError(EclipseCollectionsCodeGenerator.java:240)
        at org.stringtemplate.v4.misc.ErrorManager.runTimeError(ErrorManager.java:133)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:152)
        at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:742)
        at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:674)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.ST.write(ST.java:427)
        at org.stringtemplate.v4.ST.render(ST.java:497)
        at org.stringtemplate.v4.ST.render(ST.java:491)
        at org.stringtemplate.v4.ST.render(ST.java:487)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator.executeTemplate(EclipseCollectionsCodeGenerator.java:162)
        at org.eclipse.collections.codegenerator.EclipseCollectionsCodeGenerator.generateFiles(EclipseCollectionsCodeGenerator.java:112)
        at org.eclipse.collections.codegenerator.maven.GenerateMojo.execute(GenerateMojo.java:79)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Eclipse Collections Parent Project ................. SUCCESS [  0.317 s]
[INFO] Eclipse Collections Code Generator ................. SUCCESS [  1.471 s]
[INFO] Eclipse Collections Code Generator Ant Task ........ SUCCESS [  0.579 s]
[INFO] Eclipse Collections Code Generator Maven Plugin .... SUCCESS [  1.300 s]
[INFO] Eclipse Collections API ............................ SUCCESS [  6.791 s]
[INFO] Eclipse Collections Main Library ................... SUCCESS [ 38.458 s]
[INFO] Eclipse Collections Test Utilities ................. SUCCESS [  7.192 s]
[INFO] Eclipse Collections Fork Join Utilities ............ SUCCESS [  5.691 s]
[INFO] Eclipse Collections Unit Test Suite ................ FAILURE [  1.173 s]
[INFO] Eclipse Collections Scala Unit Test Suite .......... SKIPPED
[INFO] Eclipse Collections Serialization Test Suite ....... SKIPPED
[INFO] Eclipse Collections JMH Scala Test Suite ........... SKIPPED
[INFO] Eclipse Collections JMH Test Suite ................. SKIPPED
[INFO] Eclipse Collections Test Trait JUnit Runner ........ SKIPPED
[INFO] Eclipse Collections Java 8 Unit Test Suite ......... SKIPPED
[INFO] Eclipse Collections Test Coverage Aggregation ...... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

from eclipse-collections.

nikhilnanivadekar avatar nikhilnanivadekar commented on June 29, 2024

@jankotek Apologies, I could not get to this earlier. I have pushed a fix to my fork.
nikhilnanivadekar@486c658.

The issue was not with your template files. We do not have literals for boolean, so you need to write the test class for MultiReaderBooleanList by hand. Once that class is found, the build will not try to code generate it. The exception was mentioning that.

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

I added pull request for Primitive Lists, other collections will follow
#262

from eclipse-collections.

donraab avatar donraab commented on June 29, 2024

@jankotek @nikhilnanivadekar Should this issue be closed, as I see the PR mentioned #262 was closed ?

from eclipse-collections.

jankotek avatar jankotek commented on June 29, 2024

I dont have a time to work on this, sorry.

from eclipse-collections.

donraab avatar donraab commented on June 29, 2024

No worries. Thank you.

from eclipse-collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.