$Account.OrganizationName
ACE News and Tips Newsletter Helping You Make the Most of ACE
June 2006

Welcome to the June 2006 edition of Riverace's ACE News and Tips newsletter. This issue contains information about an important change to the ACE_Task class, a note about the upcoming How to Use ACE Effectively class (Sign up by September 1 to ensure you get the $200 discount!!!), and a reminder about supported platform changes in ACE.

In this issue
  • Featured Book: C++ Network Programming, Volume 1 (C++NPv1)
  • Important Change: ACE_Task::last_thread()
  • ACE Platforms: What's Out?
  • Next "How to Use ACE Effectively" Class: October 17-20, 2006

  • Important Change: ACE_Task::last_thread()

    The ACE_Task class is often used to implement multithreaded processing in ACE applications. Since ACE_Svc_Handler inherits from ACE_Task, you're using ACE_Task when writing applications that use the Acceptor-Connector framework as well as when directly using ACE_Task in situations such as thread pool.

    Since many ACE_Task objects are dynamically allocated and, thus, must be freed correctly when no longer needed, knowing when the object can be deleted is very important. C++NPv2 page 189 describes a method for using the ACE_Task::thr_count() method to determine when it is safe to delete the task object in situations where multiple threads refer to a task object and they're exiting.

    Recently Howard Finer, a long-time ACE user, described a case where the C++NPv2-documented procedure was not safe. Here's why:

    • ACE decrements the task's thread count before calling the ACE_Task::close() hook
    • The lock serializing access to the task's thread count is not held across the call to ACE_Task::close() since the close hook may delete the task object
    • Thus, it's possible that multiple threads checking the value of ACE_Task::thr_count() could see the value 0
    For example, let's say there are two threads, A and B, which are both exiting. Thread A returns control from its svc() method and ACE begins the thread record-keeping. ACE obtains the task's lock and decrements the active thread count from 2 to 1. ACE then releases the lock and calls the task's close() hook. Meanwhile, thread B also returns from its svc() method. Before thread A can check the value of ACE_Task::thr_count(), thread B's cleanup in ACE may cause the task's thread count to be decremented from 1 to 0. If so, both thread A and thread B will see the thread count as 0 and both attempt to clean up the task object. This is not good...

    Because Howard is a Riverace support customer, Riverace took the lead in working out a solution with Howard and the ACE developer group. After a number of iterations and trials, Howard developed the idea of having ACE, in addition to maintaining the thread count, remember which thread is actually the one that decrements the task's thread count to 0 (thread B in the example above). This led to the new method:
    ACE_thread_t ACE_Task::last_thread (void) const

    Thus, code in your application's implementation of ACE_Task::close () should include a check such as this:
    if (ACE_OS::thr_equal (ACE_Thread::self (),
                           this->last_thread ()))
      {
        // Do the cleanup here...
      }

    The new method will be available in the ACE 5.5.2 beta, which should be available within a week. It will also be in the forthcoming ACE 5.5a Fix Kit from Riverace. We usually don't include API changes in Fix Kits, but this one resolves an important issue.


    ACE Platforms: What's Out?

    The March 2006 edition of this newsletter listed a number of changes to the supported platforms for ACE. Part of the ACE development community's work on the next version of ACE involves removing code, configurations, workarounds, etc. for platforms that are no longer supported. The ACE 5.5.2 beta will be the first post-ACE 5.5 beta with some of these removals in effect.

    As a reminder, these platforms are no longer supported in the ACE development stream:

    • HP-UX 11.00, all compilers
    • Solaris with the Sun Forte 7 compiler
    • Windows with the Microsoft Visual C++ 6 compiler
    Please note that Riverace will continue to support these platforms in ACE 5.5 (and 5.4) as long as we support ACE 5.4 and 5.5. Please refer to our ACE Support page for complete platform support details.


    Next "How to Use ACE Effectively" Class: October 17-20, 2006

    Have you ever felt like screaming when faced with the ACE Reference Documentation? We can help sort it all out and get you programming with ACE like a pro! We've scheduled an open enrollment How to Use ACE Effectively class for October 17-20, 2006 in Waltham, MA (in the Boston area). This is a new expanded 4-day class, priced at US$1,700 (discounted to $1500 for online enrollments by September 1) including continental breakfast, snacks and lunch each day. Each attendee receives a copy of the class slides and a copy of The ACE Programmer's Guide (one of the authors, Steve Huston, will be teaching the class and would be happy to sign anyone's book.

    For more information and to sign up, please click on the "October 17-20, 2006" link at our training page. You'll also find a PDF file for multiple enrollments and for payment other than by credit card. That form is also available here.

    Also, please note that attendees get a 10% savings on ACE Annual Support purchased when you pay for your class! Take advantage of this opportunity to make the most of your new ACE knowledge and keep the momentum going back at the office with quick answers and direction on your project's issues!


    Featured Book: C++ Network Programming, Volume 1 (C++NPv1)

    Now in its third printing, this acclaimed book covers C++ network programming, including an overview and strategies for addressing common development challenges, and an introduction to the ACE Toolkit. With this book and ACE, C++ developers have at their disposal the most complete toolkit available for developing successful, multiplatform, concurrent networked applications with ease and efficiency.

    Buy it now from amazon.com...
    Quick Links...

    ACE Documentation

    ACE 5.4 Series Kits

    Latest ACE 5.5 Kit

    ACE Training Classes

    ACE Support Services

    Newsletter Archive

    More About Us



    Join our mailing list!
    phone: 888-384-8154