GithubHelp home page GithubHelp logo

Comments (3)

levlam avatar levlam commented on May 17, 2024

I have an application that is split into multiple threads

This splitting is expected from a GUI application.

You can use td_send from any thread, but the way you dispatch response on the same thread depends on the programming language and framework you use. In some programming languages the best way is to use coroutines, in others you can use callbacks and framework-provided way to dispatch events between threads. In any case, you need an asynchronous scheduler provided by the programming language implementation or framework to simplify communication between threads.

from td.

somedev09 avatar somedev09 commented on May 17, 2024

My application will have a TUI interface and it is written in C++. I have a separate class for TDLib, in its constructor the TDLib update loop starts. This loop calls the get_authorization_state method, but I need to be able to call it in another thread too.

from td.

levlam avatar levlam commented on May 17, 2024

You must process responses asynchronously, so you need the ability to process response on another thread. Instead of full processing, you can just dispatch response to the original thread, but in any case you need the way to save request context and send data to other threads. For this you need some kind of multithread queues/multithread event dispatcher/multithread scheduler. There are a lot of decent already existing implementations of those, but I can't recommend any particular one.

from td.

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.