All Projects → Squadrick → Shadesmar

Squadrick / Shadesmar

Licence: mit
Fast C++ IPC using shared memory (with msgpack)

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Shadesmar

Sharedhashfile
Share Hash Tables With Stable Key Hints Stored In Memory Mapped Files Between Arbitrary Processes
Stars: ✭ 380 (+201.59%)
Mutual labels:  shared-memory, ipc, high-performance
Notlitecode
Remote Encrypted Procedure Calling for .Net & .Net Core
Stars: ✭ 16 (-87.3%)
Mutual labels:  rpc, high-performance
Brpc Java
Java implementation for Baidu RPC, multi-protocol & high performance RPC.
Stars: ✭ 647 (+413.49%)
Mutual labels:  rpc, high-performance
Discordipc
Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate
Stars: ✭ 66 (-47.62%)
Mutual labels:  rpc, ipc
Ipc
IPC is a C++ library that provides inter-process communication using shared memory on Windows. A .NET wrapper is available which allows interaction with C++ as well.
Stars: ✭ 332 (+163.49%)
Mutual labels:  shared-memory, ipc
Cpp Ipc
C++ IPC Library: A high-performance inter-process communication using shared memory on Linux/Windows.
Stars: ✭ 420 (+233.33%)
Mutual labels:  shared-memory, ipc
Scalecube Services
v2.0 - ScaleCube Services provides a low latency Reactive Microservices library for serverless service registry and discovery based on gossip protocol and without single point-of-failure or bottlenecks.
Stars: ✭ 23 (-81.75%)
Mutual labels:  rpc, ipc
Ecal
eCAL - enhanced Communication Abstraction Layer
Stars: ✭ 292 (+131.75%)
Mutual labels:  shared-memory, ipc
Rsf
已作为 Hasor 的子项目,迁移到:http://git.oschina.net/zycgit/hasor
Stars: ✭ 77 (-38.89%)
Mutual labels:  rpc, high-performance
Jocket
Low-latency java socket implementation (using shared memory)
Stars: ✭ 83 (-34.13%)
Mutual labels:  shared-memory, ipc
Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+988.89%)
Mutual labels:  rpc, high-performance
Tarsjava
Java language framework rpc source code implementation
Stars: ✭ 321 (+154.76%)
Mutual labels:  rpc, high-performance
Zanphp
PHP开发面向C10K+的高并发SOA服务 和RPC服务首选框架
Stars: ✭ 1,451 (+1051.59%)
Mutual labels:  rpc, high-performance
Xxl Rpc
A high performance, distributed RPC framework.(分布式服务框架XXL-RPC)
Stars: ✭ 493 (+291.27%)
Mutual labels:  rpc, high-performance
Saea
SAEA.Socket is a high-performance IOCP framework TCP based on dotnet standard 2.0; Src contains its application test scenarios, such as websocket,rpc, redis driver, MVC WebAPI, lightweight message server, ultra large file transmission, etc. SAEA.Socket是一个高性能IOCP框架的 TCP,基于dotnet standard 2.0;Src中含有其应用测试场景,例如websocket、rpc、redis驱动、MVC WebAPI、轻量级消息服务器、超大文件传输等
Stars: ✭ 318 (+152.38%)
Mutual labels:  rpc, high-performance
Rpc Thunderdome
A comparison between Proteus RPC and other commonly used RPC frameworks
Stars: ✭ 22 (-82.54%)
Mutual labels:  rpc, ipc
Tarscpp
C++ language framework rpc source code implementation
Stars: ✭ 261 (+107.14%)
Mutual labels:  rpc, high-performance
Joyrpc
high-performance, high-extensibility Java rpc framework.
Stars: ✭ 290 (+130.16%)
Mutual labels:  rpc, high-performance
Traffic Shm
traffic-shm (Anna) is a Java based lock free IPC library.
Stars: ✭ 72 (-42.86%)
Mutual labels:  shared-memory, ipc
Dapeng Soa
A lightweight, high performance micro-service framework
Stars: ✭ 101 (-19.84%)
Mutual labels:  rpc, high-performance

Shadesmar

C/C++ CI

Soulcast hoid pointers.

An IPC library that uses the system's shared memory to pass messages. The communication paradigm is either publish-subscibe or RPC similar to ROS and ROS2.

Required packages: Msgpack

Caution: Pre-alpha software.

Features

  • Multiple subscribers and publishers.

  • Multithreaded RPC support.

  • Uses a circular buffer to pass messages between processes.

  • Faster than using the network stack like in the case with ROS.

  • Decentralized, without resource starvation.

  • Allows for both serialized message passing (using msgpack) and to pass raw bytes.

  • No need to define external IDL files for messages. Use C++ classes as message definition.


Publish-Subscribe

Publisher:

#include <shadesmar/memory/copier.h>
#include <shadesmar/pubsub/publisher.h>

int main() {
    shm::memory::DefaultCopier cpy;
    shm::pubsub::Publisher pub("topic_name", &cpy);
    const uint32_t data_size = 1024;
    void *data = malloc(data_size);
    
    for (int i = 0; i < 1000; ++i) {
        p.publish(msg, data_size);
    }
}

Subscriber:

#include <shadesmar/memory/copier.h>
#include <shadesmar/pubsub/subscriber.h>

void callback(shm::memory::Memblock *msg) {
  // `msg->ptr` to access `data`
  // `msg->size` to access `size`

  // The memory will be free'd at the end of this callback.
  // Copy to another memory location if you want to persist the data.
  // Alternatively, if you want to avoid the copy, you can call
  // `msg->no_delete()` which prevents the memory from being deleted
  // at the end of the callback.
}

int main() {
    shm::memory::DefaultCopier cpy;
    shm::pubsub::Subscriber sub("topic_name", &cpy, callback);

    // Using `spinOnce` with a manual loop
    while(true) {
        sub.spin_once();
    }
    // OR
    // Using `spin`
    sub.spin();
}

Publish-Subscribe (serialized messages)

For plug-and-play convenience Shadesmar supports msgpack serialization.

Message Definition (custom_message.h):

#include <shadesmar/message.h>

class InnerMessage : public shm::BaseMsg {
  public:
    int inner_val{};
    std::string inner_str{};
    SHM_PACK(inner_val, inner_str);

    InnerMessage() = default;
};

class CustomMessage : public shm::BaseMsg {
  public:
    int val{};
    std::vector<int> arr;
    InnerMessage im;
    SHM_PACK(val, arr, im);

    explicit CustomMessage(int n) {
      val = n;
      for (int i = 0; i < 1000; ++i) {
        arr.push_back(val);
      }
    }

    // MUST BE INCLUDED
    CustomMessage() = default;
};

Publisher:

#include <shadesmar/pubsub/serialized_publisher.h>
#include <custom_message.h>

int main() {
    shm::pubsub::SerializedPublisher<CustomMessage> pub("topic_name");

    CustomMessage msg;
    msg.val = 0;

    for (int i = 0; i < 1000; ++i) {
        p.publish(msg);
        msg.val++;
    }
}

Subscriber:

#include <iostream>
#include <shadesmar/pubsub/serialized_subscriber.h>
#include <custom_message.h>

void callback(const std::shared_ptr<CustomMessage>& msg) {
    std::cout << msg->val << std::endl;
}

int main() {
    shm::pubsub::SerializedSubscriber<CustomMessage> sub("topic_name", callback);

    // Using `spinOnce` with a manual loop
    while(true) {
        sub.spin_once();
    }
    // OR
    // Using `spin`
    sub.spin();
}

RPC (Currently broken)

Server:

#include <shadesmar/rpc/server.h>

int add(int a, int b) {
  return a + b;
}

int main() {
  shm::rpc::Function<int(int, int)> rpc_fn("add_fn", add);

  while (true) {
    rpc_fn.serve_once();
  }

  // OR...

  rpc_fn.serve();
}

Client:

#include <shadesmar/rpc/client.h>

int main() {
  shm::rpc::FunctionCaller rpc_fn("add_fn");

  std::cout << rpc_fn(4, 5).as<int>() << std::endl;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].