Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3486674
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:03:31+00:00 2026-05-18T11:03:31+00:00

The goal is to have a single-threaded event-driven framework. The end-user will do something

  • 0

The goal is to have a single-threaded event-driven framework. The end-user will do something like:

class MyEventFramework : public EventFramework {
protected:
  virtual void onData (const Data& data);
  virtual void onReport (const Report& report);
  virtual void onUserRequest (const UserRequest& userRequest);
...
};

There are other components behind the scenes, like a series of timers, etc.

Most of these handlers are called by my own code, so I can use select() or a similar concept (kqueue(), epoll(), etc) over a series of file descriptors.

My issue is that the onData() routine is actually a callback from a third-party library, which I don’t have the source code for. Therefore, I can’t just use their file descriptor; I only know that something has happened via the callback.

Right now I have a multithreaded implementation of my framework; the logic leading up to onData() occurs in a separate thread before reaching the user. This is undesirable because it necessitates error-prone mutex locks, requires expensive thread switching (this is a low-latency application), and other problems. (To clarify, each handler in the framework must be atomic with respect to each other because of the potential for race conditions in the client application.)

Has anyone else encountered this before and lived to tell the tale?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:03:32+00:00Added an answer on May 18, 2026 at 11:03 am

    If I understand correctly : your dispatching thread is blocked on some system call (say select or poll), and you would like the onData member function to follow the same notification path.

    Using a pipe seems like a good solution to me without hurting the design too much :

    • select monitors one end of the pipe
    • the 3rd library callbacks ‘rings’ the other end of the pipe when called

    This allows for a ‘thread jump’, the only issue being that the pipe should only be used as a notification facility : the parameter to the onData function will have to be queued somewhere between the pipe notification and the processing thread wake-up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So my goal here is to have a single search field in an application
My Goal I would like to have a main processing thread (non GUI), and
We have a bunch of user controls we would like to pull out of
I have a highly dynamic single page interface where various user events trigger new
The goal I would love to have a multi user system (based on linux)
I'm working on a Silverlight Polling control. My goal is to have a Button
I have an Events table whose goal is to store actions done by web
I have a decimal number (let's call it goal ) and an array of
I have a fairly simple addition to the HTTP standard. An ambitious goal I
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.