Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The support of multiple producers #67

Open
Yanjiachan opened this issue Jun 27, 2023 · 0 comments
Open

The support of multiple producers #67

Yanjiachan opened this issue Jun 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Yanjiachan
Copy link

Yanjiachan commented Jun 27, 2023

If multiple producers are employed, it could lead to a blockage at the location of the following code:

https://github.com/Squadrick/shadesmar/blob/master/include/shadesmar/pubsub/topic.h#L136

Below is my test code

struct stu {
    int a = 0;
    char b[10] = {0};
};

int test() {
  auto sp_pub = make_shared<Publisher>("test_shared_topic");
  if (!sp_pub) {
      return -1;
  }
  int i = 0;
  while(true) {
      struct stu s;
      s.a = i++;
      string str = to_string(i);
      strncpy(s.b, str.c_str(), str.length());
      bool ret = sp_pub->publish(reinterpret_cast<void*>(&s), sizeof(stu));
      if (!ret) {
          cout << "publish error" << endl;
      }
      this_thread::sleep_for(chrono::milliseconds(1));
  }
  return 0;
}

I spawn multiple processes to execute the above code.

@Squadrick Squadrick added the bug Something isn't working label Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants