Git Product home page Git Product logo

cosim4j's People

Contributors

markaren avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cosim4j's Issues

Switch to CMake for building the JNI wrapper

cse-core4j still does not work under Windows. We currently use Gradle and the highly experimental and undocuemted cpp-plugin for building the JNI code. Lets try CMake to see if that makes a difference.

Add CI

We should add CI. I only know how to use CircleCI, which takes about 1 minute to set up. But since this is a private repo, we can't use it unless we buy it (9$ a month).

Someone willing to setup travis Jenkins CI similar to cse-core?

Clone the project and run:

./gradlew test

Disable Jenkins

With Github Actions configured, there is no longer need for the Jenkins build I guess?
@hplatou In addition to removing the checked in Jenkinsfile, I guess there are something you need to do on your end?

Add JVM slave

Make it possible to create slaves in Java code.

There will be some issues since CSE uses boost::fibers, but we can reuse the solution used when I implemented the callback feature.

Change package

org.osp is not owned by us. Need to change. Either a github package name or use ntnu namespace.

Improve readme file

Improve readme to give some guidance on how to be able to use cosim4j. How to build and include in a project, for example.

CSE should be pre-installed on the target system

The initial design of this module was that all relevant native libs should be bundled with the .jar. This is easier said then done. An alternative solution is to require that CSE is pre-installed on the target system, and naturally added to PATH.

Invalidates #2

Callback is broken in conjunction with cse::execution.start()

Step event listener is broken in conjunction with cse::execution.start().

Possible related: https://stackoverflow.com/questions/19092602/context-switched-native-thread-cant-attach-to-jvm

It seems you cannot do callbacks to Java when using boost::fibers.

@kyllingstad @mrindar Any insights?

This is my current code:

cse::step_event_listener::step_event_listener(JNIEnv* env, jobject listener)
{
    env->GetJavaVM(&jvm_);
    jclass cls = env->GetObjectClass(listener);
    mid_ = env->GetMethodID(cls, "post", "()V");
    listener_ = env->NewGlobalRef(listener);
}

void cse::step_event_listener::step_complete(cse::step_number lastStep, cse::duration lastStepSize, cse::time_point currentTime)
{

    JNIEnv* env;
    bool attach = false;
    jint getEnvStat = jvm_->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
    if (getEnvStat == JNI_EDETACHED) {
        jvm_->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr);
        attach = true;
    }

    env->CallVoidMethod(listener_, mid_);

    if (attach) {
        jvm_->DetachCurrentThread();
    }
    
}

cse::step_event_listener::~step_event_listener()
{
    
    JNIEnv* env;
    bool attach = false;
    jint getEnvStat = jvm_->GetEnv((void**)&env, JNI_VERSION_1_6);
    if (getEnvStat == JNI_EDETACHED) {
        jvm_->AttachCurrentThread((void**)&env, nullptr);
        attach = true;
    } 

    env->DeleteGlobalRef(listener_);

    if (attach) {
        jvm_->DetachCurrentThread();
    }
    
}

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.