Giter Site home page Giter Site logo

Comments (2)

sakshamsharma avatar sakshamsharma commented on August 23, 2024

Actually while attempting to fix this, I realized that this won't be a very holistic solution.
https://github.com/sakshamsharma/cli/commits/plugin
Well, it works. But only for local sessions.

Basically, any such approach will be helpless when it comes to network data on boost sockets. It appears that boost does not take kindly to other dispatchers trying to do its job ( :sad: ).

Until then, I have adopted a different approach for this, where I launch one thread with an ios.run(), and I made my CmdHandler lambdas (running in the boost dispatcher thread) push lambdas into my own select based dispatcher.

from cli.

daniele77 avatar daniele77 commented on August 23, 2024

First of all, are you sure boost asio can’t manage file descriptors? Take a look at this page:
https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/overview/posix/stream_descriptor.html

Sorry, but I can’t understand the problem you’re trying to solve in the first place.

Cli handlers all run in the thread that invokes run() on the io_service passed on the cli constructor.
If your application runs in other threads, than you simply needs a way to communicate from one thread to the other.
The right way depends on how works your threads. You wrote that your application has got a dispatcher, so I guess you have a way to send events to it: eg if sending events is an atomic operation / is synchronized, you can safely send events from cli handlers to your dispatcher.
How to reach your dispatcher is another problem again. If you have just one in all the application, you can use the singleton pattern to get the unique instance from inside the cli handlers.

from cli.

Related Issues (20)

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.