GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ShirasawaSama/JavaSharedMemory: Shared memory between Java and C++/Rust/Go processes.

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
include
include
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
jitpack.yml
jitpack.yml
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

JavaSharedMemory Jitpack

Shared memory between processes. (Java, C++, Rust, etc.) Based on Java 19 Foreign Function & Memory API

Support Windows (CreateFileMapping), Linux and macOS (mmap and shmget).

Note Compared with standard input and output (anonymous pipes) on Windows, more than 2x performance improvement.

Usage

Java

repositories {
    maven { url 'https://www.jitpack.io' }
}

dependencies {
    implementation 'com.github.ShirasawaSama:JavaSharedMemory:<version>'
}

tasks.withType(JavaCompile).each {
    it.options.compilerArgs.add('--enable-preview')
}

// kotlin script
// tasks.withType<JavaCompile> {
//     options.compilerArgs = options.compilerArgs + listOf("--enable-preview")
// }
import cn.apisium.shm;

public class Main {
    public static void main(String[] args) {
        // var shm = SharedMemory.open("test", 1024)
        try (var shm = SharedMemory.create("test", 1024)) {
            var buf = shm.toByteBuffer();
            buf.put("Hello, World!".getBytes());
        }
    }
}

C++

git submodule add https://github.com/ShirasawaSama/JavaSharedMemory.git

CMakeLists.txt:

add_subdirectory(JavaSharedMemory)
target_link_libraries(${PROJECT_NAME} java_shared_memory)

main.cpp:

#include <jshm.h>

int main() {
    auto shm = jshm::shared_memory::create("test", 1024);
    // auto shm = jshm::shared_memory::open("test", 1024);
    strcpy((char*)shm->address(), "Hello, World!");
    delete shm;
}

Author

Shirasawa

License

MIT

About

Shared memory between Java and C++/Rust/Go processes.

Topics

cppffiinterprocessinterprocess-communicationipcjavajava-19pure-javashared-memory

Resources

Readme
MIT license
Activity

Stars

30 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.