ryukware
C++ Asynchronous Delegate for Microsoft Windows
- 2007年12月12日 3:07 AM
- 未分類
Microsoft Windows 2000 and later have a very useful system function to make an asynchronous function call, QueueUserWorkItem. With this function and its thread pool that is aware of what Windows is actually doing at a given time, Windows takes care of all asynchronous function call complicatedness for you in the simplest form. This high-level function is a god-send for lazy programmers who want to concentrate on what an application can do in a reasonable performance range rather than how it does things with the smallest performance hit.
But people can never be lazy enough, setting it up with context information each time will soon become a boring task especially when you want to asynchronously call a member function of a foreign C++ object. But you don’t want to make it completelly dynamic, either. You have to manually write a wrapper function since QueueUserWorkItem is a mere C function that knows jack about C++. This article introduces a small toolkit AsyncDelegate.h that lends itself to solving this issue by using C++ templates.Microsoft Windows 2000 and later have a very useful system function to make an asynchronous function call, QueueUserWorkItem. With this function and its thread pool that is aware of what Windows is actually doing at a given time, Windows takes care of all asynchronous function call complicatedness for you in the simplest form. This high-level function is a god-send for lazy programmers who want to concentrate on what an application can do in a reasonable performance range rather than how it does things with the smallest performance hit.
But people can never be lazy enough, setting it up with context information each time will soon become a boring task especially when you want to asynchronously call a member function of a foreign C++ object. But you don’t want to make it completelly dynamic, either. You have to manually write a wrapper function since QueueUserWorkItem is a mere C function that knows jack about C++. This article introduces a small toolkit AsyncDelegate.h that lends itself to solving this issue by using C++ templates. 続きを読む
- 検索
- フィード
- メタ情報