Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Using COM+ object pooling with Delphi 6

 URL: http://edn.embarcadero.com/article/27568
Abstract: Delphi 6 introduces support for COM+ object pooling, which can provide significant performance improvements under some circumstances. We take a look at Delphi 6s object pooling support. By Vincent Parrett.
Typically, when a client application instantiates a COM+ object, the COM+ runtime will create a new instance of the object. When your client is done with the object, COM+ will destroy the object. This all makes for very efficient use of memory resources, and under normal loads provides quite an acceptable performance.
However, under higher loads the creation and destruction of objects can become a substantial overhead. This is especially true if your COM+ objects are themselves allocating resources, instantiating other objects, and so on.
Object pooling can help in these situations by reducing the number of times an object must be instantiated or destroyed. When pooling is in effect, a client's request for an object will kick of a search to see if there is a ready-to-use object pool for objects of the appropriate type. If so, the COM+ system will provide and activate the object. If not, COM+ will create a new object. When the client is done with the object, COM+ will not destroy the object, but will return it to the object pool so it can be reused.
To get the best out of COM+, your objects should be stateless. To make use of object pooling, they must be stateless objects.
Object pooling with Delphi 6
Supporting object pooling in Delphi 6-generated COM+ objects is simple, however there are a few things that you need to take care with:
Threading model
The first is that you must select the Both threading model, otherwise object pooling will be disabled.
If you get this wrong, don't worry -- it's easy to fix. The New Transactional Object wizard generates code that looks something like this :
initialization
TAutoObjectFactory.Create(ComServer, TMyCOMPlusObject, Class_MyCOMPlusObject,
ci


Ïà¹ØÎĵµ£º

delphi×ÊÔ´ÎļþÖÆ×÷¼°Ê¹ÓÃÏê½â

Ò»¡¢Òý×Ó£º
ÏÖÔÚµÄWindowsÓ¦ÓóÌÐò¼¸ºõ¶¼Ê¹ÓÃͼ±ê¡¢Í¼Æ¬¡¢¹â±ê¡¢ÉùÒôµÈ£¬ÎÒÃdzÆËüÃÇΪ×ÊÔ´£¨Resource£©¡£×î¼òµ¥µÄʹÓÃ×ÊÔ´µÄ°ì·¨ÊÇ°ÑÕâЩ×ÊÔ´µÄÔ´Îļþ´òÈëÈí¼þ°ü£¬ÒÔ·½±ã³ÌÐòÐèÒªµÄʱºòµ÷Óá£×ÊÔ´ÊdzÌÐòµÄÒ»²¿·Ö£¬³ÌÐòÒªÕý³£ÔËÐоÍÀë²»ÁË×ÊÔ´Îļþ¡£µ«ÊÇËüÊDz»¿ÉÖ´ÐдúÂë¡£
ΪÁ˸üºÃµØ¹ÜÀí×ÊÔ´£¬DelphiÖÐÌṩÁËÒ»ÖÖ.RESÀàÐ ......

Delphi Êý¾ÝÀàÐÍ

 Ò»¡¢ÕûÊýÀàÐÍ
ÀàÐÍ ËùÕ¼×Ö½ÚÊý È¡Öµ·¶Î§
byte 1 0-255
word 2 0-65535
shortint 1 -128-127
smallint 2 -32768-32767
integer 4 -214748648-214748467
longint 4 -214748648-214748467
cordinal 4 0-2147483647
¶þ¡¢ÊµÊýÀàÐÍ
ÀàÐÍ Ëùµã×Ö½ÚÊý È¡Öµ·¶Î§
Real 6 ±2.9×10µÄ¸º39´Î·½µ½1.7× ......

ÖÕÓڸ㶨ÁËDelphiµÄUnicodeÖ§³Ö(Tnt¿Ø¼þ)

Ô­À´ÊÇÒªÔÚFormCreateÖмÓÈëÒÔÏ´úÂë:
procedure TTntForm1.TntFormCreate(Sender: TObject);
begin
  //Õâ¾äºÜ¹Ø¼ü.¶ÔÓÚƽ̨µÄÖ§³Ö.
  if Win32Platform = VER_PLATFORM_WIN32_NT then
    Font.Name := 'MS Shell Dlg 2'
  else
    Font.Name := 'MS Shell Dlg';
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ