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

  • SEARCH
  • Home
  • 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 8306785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:23:56+00:00 2026-06-08T18:23:56+00:00

I understand a running asio service is like a queue I can use to

  • 0

I understand a running asio service is like a queue I can use to post tasks a thread will execute sequentially. However, as any queue, I guess there are limits. Is it possible to set this limit for asio services? Is it possible to set what policy to follow when the queue is full (i.e. blocking, non blocking, etc.)?

UPDATE

Suppose I have a thread running an asio::service and a timer posting each 10ms a task to this thread. The task reception is bound to a method invokation which will make the thread sleeping for 100ms. I have therefore a timer posting 100 tasks a second to a thread which is capable of performing 10 tasks each second. It is evident that this situation will diverge. However, when dealing with queues, there are usually means to dimension the queue deepness (100? 1000? posts enqueued, etc.) or to specify the policy a sender should follow when the queue is full (i.e. shall it wait or shall it drop the request and continue?). My question is Ho to set these features in asio::service?

  • 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-06-08T18:23:57+00:00Added an answer on June 8, 2026 at 6:23 pm

    Asio does not provide policies to control the internal data structures. However, it does provide hooks into handler allocations: asio_handler_allocate and asio_handler_deallocate. These hooks can be used by an application to limit the amount of outstanding asynchronous operations, as well as defining the behavior when the user specified limit is reached.

    There are a few key points to consider:

    • asio_handler_allocate is expected to return a valid memory block or throw an exception. If an exception is thrown from asio_handler_allocate, it will continue unwinding the stack through calls like io_service::post(). Thus, for a non-blocking behavior when the max is reached, throwing may be the only option.
    • Consider the effects on composed operations, such as async_read, where asio_handler_allocate and asio_handler_deallocate may be called multiple times. If an exception is thrown, a thread’s stack will unwind to at least the point at which io_service::run was invoked. If blocking occurs, then it could be possible to have all threads servicing the reactor to become blocked, essentially preventing all asynchronous jobs from completing.

    Here is an allocation example from the Boost.Asio examples showing a memory-pool being used for handlers.

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

Sidebar

Related Questions

Sorry for long winded post. I am trying to understand UIScrollView and running into
I understand I can create an enum like this: public enum MyEnum { ONE(1),
I'm running into some problems trying to understand how I can do this. Let's
I'm running Python 2.6.6 on Ubuntu 10.10. I understand that we can import a
Is there any way that I can understand that my code is running with
I can't understand why running my Python program just opens IDLE. Not sure if
From what I understand about twisted, nothing running in the reactor thread should block.
by my understand about looper that it's can be a central for running by
I'm running wget through php's shell_exec() How could I understand that wget got 404
I've been trying to understand how to start writing and running JUnit tests. When

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.