skip to main content
10.1145/1753196.1753218acmconferencesArticle/Chapter ViewAbstractPublication PagesplopConference Proceedingsconference-collections
research-article

Deferred cancellation: a behavioral pattern

Published: 18 October 2008 Publication History

Abstract

People who design their own pool of worker threads [33, pp 290--298] or processes have to consider how to shut down the workers again or how to dynamically adapt the number of workers to varying load. Especially with regard to application termination you may have the choice between an immediate destruction of the pool and a more graceful shutdown. The pattern proposed helps to portably implement such termination and load adaptation mechanisms that assume you voted for the second choice. The main area of application are the internals of active objects [40] and similar designs that delegate work to a pool of threads or processes to execute service requests asynchronously from their actual invocation.
For the pattern proposed we identified usage examples in popular existing applications or libraries.
Both a real world example and sample code accompany the pattern presentation. This sample code is in C++.
The presentation of the pattern follows the style well known from [11] and [44]. This pattern is based upon other patterns. Typographic conventions for references to other patterns are similar to [3]. A Glossary provides thumbnails of many of these patterns.

References

[1]
Releasing resources in Java. published online. http://www.c2.com/cgi/wiki?ReleasingResourcesInJava, visited on January 9, 2007.
[2]
Preliminary conference proceedings of EuroPLoP '96. Tech. Rep. wucs-97-07, Washington University, Department of Computer Science, 1997.
[3]
Alexander, C., S. Ishikawa, and M. Silverstein: A Pattern Language. Towns, Buildings, Construction. With Max Jacobson, Ingrid Fiksdahl--King and Shlomo Angel. Oxford University Press, New York, 1977, ISBN 0-19-501919-9.
[4]
American National Standards Institute, New York, NY: ISO / IEC 14882:2003(E). Programming languages---C++. Langages de programmation---C++, International Standard, second ed., Oct. 2003, ISBN 0-470-84674-7.
[5]
Arnold, K., J. Gosling, and D. Holmes: Die Programmiersprache Java. Deutsche Übersetzung von RederTranslations, Dorothea Reder und Gabi Zöttl. Programmer's Choice. Addison--Wesley. An Imprint of Pearson Education, München · Boston · San Francisco · Harlow, England · Don Mills, Ontario · Sydney · Mexico City · Madrid · Amsterdam, 2001, ISBN 3-8273-1821-1. German translation of "The Java Programming Language. Third Edition".
[6]
Bachmann, P.: Change of authority and thread safe interface goes synchronized. In Proceedings of the 12th Pattern Languages of Programs (PLoP) conference 2005, Allerton Park, Monticello, IL, USA, Dec. 2005. http://hillside.net/plop/2005/proceedings/PLoP2005_pbachmann1_0.pdf, visited on January 9, 2007.
[7]
Bachmann, P.: Static and metaprogramming patterns and static frameworks. A catalog. An application. In Yoder, J. and Johnson {60}, pp. 1--33, ISBN 978-1-60558-372-3. http://hillside.net/plop/2006/Papers/ACM_Version/Static_and_Metaprogramming_Patterns_and_Static_Frameworks.pdf, visited on November 30, 2008.
[8]
Baker, Jr., H. C. and C. Hewitt: The incremental garbage collection of processes. SIGPLAN Notices, 12(8):55--59, Aug. 1977, ISSN 0362-1340. Proceedings of the 1977 Symposium on Artificial Intelligence and Programming Languages.
[9]
Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal: Command--Processor, ch. 3: Entwurfsmuster, pp. 277--291. In {11}, 1998, 1. korr. nachdruck ed., 2000, ISBN 3-8273-1282-5. German translation of "Command Processor".
[10]
Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal: Layers, ch. 2: Architekturmuster, pp. 32--53. In {11}, 1998, 1. korr. nachdruck ed., 2000, ISBN 3-8273-1282-5. German translation of "Layers".
[11]
Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal: Pattern--orientierte Softwarearchitektur. Ein Pattern--System, deutsche Übersetzung von Christiane Löckenhoff. Addison--Wesley. An Imprint of Pearson Education, München · Boston · San Francisco · Harlow, England · Don Mills, Ontario · Sydney · Mexico City · Madrid · Amsterdam, 1998, 1. korr. nachdruck ed., 2000, ISBN 3-8273-1282-5. German translation of "Pattern--Oriented Software Architecture. A System of Patterns".
[12]
Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal: Proxy, ch. 3: Entwurfsmuster, pp. 263--275. In {11}, 1998, 1. korr. nachdruck ed., 2000, ISBN 3-8273-1282-5. German translation of "Proxy".
[13]
Butenhof, D. D. R.: Re: pthread_join() with a timeout?, Feb. 1998. http://groups.google.ch/group/comp.programming.threads/msg/c12d5865e26b8b9c, visited on December 10, 2008.
[14]
Butenhof, D. R.: Programming with POSIX Threads. Addison--Wesley Professional Computing Series; ed. by Brian W. Kernighan. Addison--Wesley Longman Publishing Co., Inc., Boston, Massachusetts, 1997, ISBN 0-201-63392-2.
[15]
Cargill, T.: Localized ownership: Managing dynamic objects in C++. In Vlissides, J. M. et al. {57}, ch. 1, pp. 5--18, ISBN 0-201-60734-4 / 0-201-89527-7.
[16]
Coplien, J.: C++ idioms patterns. In Harrison, N. et al. {24}, ch. 10, pp. 167--197, ISBN 0-201-43304-4.
[17]
Coplien, J. O. and D. C. Schmidt (eds.): Pattern Languages of Program Design, vol. 1 of The Software Patterns Series; ed. by John Vlissides. Addison--Wesley, Boston · San Francisco · New York · Toronto · Montreal · London · Munich · Paris · Madrid · Capetown · Sydney · Tokyo · Singapore · Mexico City, 1995, ISBN 0-201-60734-4.
[18]
Gabriel, R. P.: Writers' Workshops & the Work of Making Things. Patterns, Poetry... Addison--Wesley, Boston ·· San Francisco · New York · Toronto · Montreal · London · Munich · Paris · Madrid · Capetown · Sydney · Tokyo · Singapore · Mexico City, 2002, ISBN 0-201-72183-X.
[19]
Gamma, E., R. Helm, R. Johnson, and J. Vlissides: Befehl, ch. 5: Verhaltensmuster, pp. 273--286. In Professionelle Softwareentwicklung {20}, dritter, unveränderter nachdruck ed., 1996. German translation of "Command".
[20]
Gamma, E., R. Helm, R. Johnson, and J. Vlissides: Entwurfsmuster. Elemente wiederverwendbarer objektorientierter Software, deutsche Übersetzung von Dirk Riehle. Professionelle Softwareentwicklung. Addison--Wesley--Longman, Bonn · Reading, Massachusetts · Menlo Park, California · New York · Harlow, England · Don Mills, Ontario · Sydney · Mexico City · Madrid · Amsterdam, dritter, unveränderter nachdruck ed., 1996. German translation of "Design Patterns. Elements of Reusable Object--Oriented Software".
[21]
Gamma, E., R. Helm, R. Johnson, and J. Vlissides: Proxy, ch. 4: Strukturmuster, pp. 254--267. In Professionelle Softwareentwicklung {20}, dritter, unveränderter nachdruck ed., 1996. German translation of "Proxy".
[22]
Gamma, E., R. Helm, R. Johnson, and J. Vlissides: Zustand, ch. 5: Verhaltensmuster, pp. 398--409. In Professionelle Softwareentwicklung {20}, dritter, unveränderter nachdruck ed., 1996. German translation of "State".
[23]
Goethe, J. W. von: The sorcerer's apprentice, 1955. http://www.fln.vcu.edu/goethe/zauber_e3.html, visited on November 30, 2008, English translation of "der Zauberlehrling", 1797, by Edwin Zeydel.
[24]
Harrison, N., B. Foote, and H. Rohnert (eds.): Pattern Languages of Program Design, vol. 4 of The Software Patterns Series; ed. by John M. Vlissides. Addison--Wesley. An imprint of Addison Wesley Longman, Inc., Reading, Massachusetts · Harlow, England · Menlo Park, California · Berkeley, California · Don Mills, Ontario · Sydney · Bonn · Amsterdam · Tokyo · Mexico City, 2000, ISBN 0-201-43304-4.
[25]
Henney, K.: Executing around sequences. In Proceedings of the 5th European Conference on Pattern Languages of Programs (EuroPLoP) 2000, Irsee, Germany, July 2000. http://hillside.net/europlop/HillsideEurope/Papers/ExecutingAroundSequences.pdf, visited on January 9, 2007.
[26]
Hewitt, C., P. Bishop, and R. Steiger: A universal modular ACTOR formalism for artificial intelligence. In International Joint Conference on Artificial Intelligence (IJCAI), pp. 235--245, 1973.
[27]
Hinnant, H. E., B. Stroustrup, and B. Kozicki: A brief introduction to rvalue references. Tech. Rep. WG21/N2027 = J16/06-0097, ISO IEC JTC1 / SC22 / WG21---The C++ Standards Committee, Herb Sutter · Microsoft Corp. · 1 Microsoft Way · Redmond WA USA 98052-6399, June 2006. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html, visited on April 25, 2008.
[28]
Hirschfeld, R.: Convenience method. In Preliminary Conference Proceedings of EuroPLoP '96 {2}.
[29]
Kempf, B.: The Boost.Threads library. The C/C++ Users Journal. Advanced Solutions for C/C++ Programmers, May 2002. http://www.ddj.com/cpp/184401518, visited on May 2, 2008.
[30]
Kiczales, G., J. Lamping, A. Mendhekar, C. Maeda, C. V. Lopes, J.-M. Loingtier, and J. Irwin: Aspect--oriented programming. In Proceedings of the European Conference on Object--Oriented Programming (ECOOP), Finland, no. 1241 in Lecture Notes in Computer Science. Springer, June 1997.
[31]
Kircher, M. and P. Jain: Pattern--Oriented Software Architecture. Patterns for Resource Management. Wiley Series in Software Design Patterns. John Wiley & Sons, Ltd, Chichester, 2004, ISBN 0-470-84525-2.
[32]
Lakos, J.: Large--Scale C++ Software Design. Addison--Wesley Professional Computing Series; ed. by Brian W. Kernighan. Addison--Wesley, Boston · San Francisco · New York · Toronto · Montreal · London · Munich · Paris · Madrid · Capetown · Sydney · Tokyo · Singapore · Mexico City, 11th printing may 2002 ed., 1996, ISBN 0-201-63362-0.
[33]
Lea, D.: Concurrent Programming in Java. Design Principles and Patterns. The Java Series; Lisa Friendly, Series Editor, Tim Lindholm, Technical Editor. Addison--Wesley. An imprint of Addison Wesley Longman, Inc., Reading, Massachusetts · Harlow, England · Menlo Park, California · Berkeley, California · Don Mills, Ontario · Sydney · Bonn · Amsterdam · Tokyo · Mexico City, second ed., Nov. 1999, ISBN 0-201-31009-0.
[34]
Mattson, T. G., B. A. Sanders, and B. L. Massingill: Patterns for Parallel Programming. The Software Patterns Series; ed. by John Vlissides. Addison--Wesley, Boston · San Francisco · New York · Toronto · Montreal · London · Munich · Paris · Madrid · Capetown · Sydney · Tokyo · Singapore · Mexico City, Sept. 2004, ISBN 0-321-22811-1.
[35]
Meier, A. V.: Networking and Concurrency Patterns. hauptseminar patterns in der softwareentwicklung. published online, Feb. 2007. http://andreas.anvame.net/content/download/meiera-netpatterns-slides.pdf, visited on December 8, 2008, TUM Informatik---Lehrstuhl Brauer.
[36]
Meszaros, G.: A pattern language for improving the capacity of reactive systems. In Vlissides, J. M. et al. {57}, ch. 35, pp. 575--591, ISBN 0-201-60734-4 / 0-201-89527-7.
[37]
Meyer, B.: Object--Oriented Software Construction. Prentice Hall, Upper Saddle River, New Jersey, second ed., 1997, ISBN 0-13-629155-4.
[38]
Microsoft Developer Network (MSDN): .NET framework general reference: Common design patterns. implementing finalize and dispose to clean up unmanaged resources. published online, 2005. http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconfinalizedispose.asp, visited on January 9, 2007.
[39]
Redlich, J.-P.: CORBA 2.0. Praktische Einführung für C++ und Java, mit einem Geleitwort von Richard Mark Soley. Praktische Informatik; hrsg. von Ludwig Classen, Dieter Nedo und Gerhard Paulin. Addison--Wesley Publishing Company, Bonn · Reading, Massachusetts · Menlo Park, California · New York · Don Mills, Ontario · Harlow, England · Amsterdam · Milan · Sydney · Tokyo · Singapore · Madrid · San Juan · Seoul · Mexico City · Taipei, Taiwan, 1996, ISBN 3-8273-1060-1.
[40]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Active Object, ch. 5: Nebenläufigkeit, pp. 411--443. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Active Object".
[41]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Half--Sync / Half--Async, ch. 5: Nebenläufigkeit, pp. 473--497. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Half--Sync / Half--Async".
[42]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Leader / Followers, ch. 5: Nebenläufigkeit, pp. 499--528. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Leader / Followers".
[43]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Monitor Object, ch. 5: Nebenläufigkeit, pp. 445--471. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Monitor Object".
[44]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Pattern--orientierte Software-Architektur. Muster für nebenläufige und vernetzte Objekte, übersetzt aus dem Amerikanischen von Martina Buschmann. dpunkt.verlag, Heidelberg, 2002, ISBN 3-89864-142-2. German translation of "Pattern--Oriented Software Architecture. Volume 2: Patterns for Concurrent and Networked Objects".
[45]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Reactor, ch. 3: Ereignisverarbeitung, pp. 197--236. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Reactor".
[46]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Scoped Locking, ch. 4: Synchronisation, pp. 359--367. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Scoped Locking".
[47]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Thread--Safe Interface, ch. 4: Synchronisation, pp. 383--391. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Thread Safe Interface".
[48]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Thread-Specific Storage, ch. 5: Nebenläufigkeit, pp. 529--561. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Thread-Specific Storage".
[49]
Schmidt, D., M. Stal, H. Rohnert, and F. Buschmann: Wrapper--Facade, ch. 2: Dienstzugriff und Konfiguration, pp. 53--84. In {44}, 2002, ISBN 3-89864-142-2. German translation of "Wrapper Facade".
[50]
Schmidt, D. C: Reactor: An object behavioral pattern for concurrent event demultiplexing and event handler dispatching. In Coplien, J. O. and Schmidt {17}, ch. 29, pp. 529--545, ISBN 0-201-60734-4.
[51]
Schmidt, D. C. and C. D. Cranor: Half-sync / half-async. An architectural pattern for efficient and well--structured concurrent I/O. In Vlissides, J. M. et al. {57}, ch. 27, pp. 437--459, ISBN 0-201-60734-4 / 0-201-89527-7.
[52]
Schmidt, D. C. and I. Pyarali: The design and use of the ACE reactor. An object-oriented framework for event demultiplexing. http://www.cs.wustl.edu/~schmidt/PDF/reactor-rules.pdf, visited on January 9, 2007.
[53]
Stevens, W. R.: UNIX Network Programming, vol. 1. Networking APIs: Sockets and XTI. Prentice Hall PTR, Upper Saddle River, NJ, second ed., 1998, ISBN 0-13-490012-X.
[54]
Stroustrup, B.: Design und Entwicklung von C++. Addison--Wesley, Bonn · Paris · Reading, Massachusetts · Menlo Park, California · New York · Don Mills, Ontario · Workingham, England · Amsterdam · Milan · Sydney · Tokyo · Singapore · Madrid · San Juan · Seoul · Mexico City · Taipei, Taiwan, 1994, ISBN 3-89319-755-9. German translation of "The Design and Evolution of C++".
[55]
Stroustrup, B.: Die C++--Programmiersprache. Deutsche Übersetzung von Nicolai Josuttis und Achim Lörke. Addison--Wesley--Longman, Bonn · Reading, Massachusetts · Menlo Park, California · New York · Harlow, England · Don Mills, Ontario · Sydney · Mexico City · Madrid · Amsterdam, dritte, aktualisierte und erweiterte ed., 1998, ISBN 3-8273-1296-5. German translation of "The C++ Programming Language, Third Edition".
[56]
Thomas Hoof Produkt GmbH: Bar with spring holders, Waltrop, Germany, 2006. http://www.produkt-gmbh.de/de/produkte/kueche/bonleiste.html, visited on November 24, 2008.
[57]
Vlissides, J. M., J. O. Coplien, and N. L. Kerth (eds.): Pattern Languages of Program Design, vol. 2. Addison--Wesley. An imprint of Addison Wesley Longman, Inc., Reading, Massachusetts · Harlow, England · Menlo Park, California · Berkeley, California · Don Mills, Ontario · Sydney · Bonn · Amsterdam · Tokyo · Mexico City, 1996, ISBN 0-201-60734-4 / 0-201-89527-7.
[58]
Williams, A.: {Boost.}Thread. published online. http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html, visited on May 2, 2008.
[59]
Williams, A.: Thread interruption in the Boost Thread library, Mar. 2008. http://www.justsoftwaresolutions.co.uk/threading/thread-interruption-in-boost-thread-library. html, visited on April 27, 2008.
[60]
Yoder, J. and R. Johnson (eds.): PLoP '06: Proceedings of the 2006 conference on Pattern Languages of Programs, New York, NY, USA, 2006. ACM, ISBN 978-1-60558-372-3.

Cited By

View all
  • (2013)Build from the endProceedings of the 20th Conference on Pattern Languages of Programs10.5555/2725669.2725694(1-12)Online publication date: 23-Oct-2013
  • (2013)Patterns for internationalization and cross-cultural usabilityProceedings of the 20th Conference on Pattern Languages of Programs10.5555/2725669.2725692(1-19)Online publication date: 23-Oct-2013
  • (2012)Variability points and design pattern usage in architectural tacticsProceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering10.1145/2393596.2393657(1-11)Online publication date: 11-Nov-2012

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLoP '08: Proceedings of the 15th Conference on Pattern Languages of Programs
October 2008
295 pages
ISBN:9781605581514
DOI:10.1145/1753196
  • General Chair:
  • Joseph Yoder,
  • Program Chair:
  • Ademar Aguiar

Sponsors

In-Cooperation

  • Hillside Group: Hillside Group

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 18 October 2008

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. actor
  2. destructor
  3. patterns
  4. portability
  5. reliability

Qualifiers

  • Research-article

Conference

PLOP '08
Sponsor:
PLOP '08: Pattern Languages of Programs
October 18 - 20, 2008
Tennessee, Nashville, USA

Acceptance Rates

Overall Acceptance Rate 28 of 36 submissions, 78%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)0
Reflects downloads up to 09 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2013)Build from the endProceedings of the 20th Conference on Pattern Languages of Programs10.5555/2725669.2725694(1-12)Online publication date: 23-Oct-2013
  • (2013)Patterns for internationalization and cross-cultural usabilityProceedings of the 20th Conference on Pattern Languages of Programs10.5555/2725669.2725692(1-19)Online publication date: 23-Oct-2013
  • (2012)Variability points and design pattern usage in architectural tacticsProceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering10.1145/2393596.2393657(1-11)Online publication date: 11-Nov-2012

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media