Brief introduction about memory queue --
CUQueue and COM UQueue object
UDAParts
support@udaparts.com
Updated on January 25, 2008
1. Introduction
Development with SocketPro requires
converting data types into bytes. The conversion is not difficult at all, but it
is indeed tedious considerably. In order to ease SocketPro development, SocketPro provides a
helper class CUQueue to efficiently convert various data types into bytes and
manage memory. Later, you can effortlessly exchange a request and a returned
result in binary format into original data types at both server and client
sides. Additionally, A COM UQueue object is written from C++/ATL COM to assist
old VB6 and other development languages to convert data types into bytes. For
how to use the COM object, you can see the attached sample udemoVB client
application inside the directory of ..\samples\client\vb\udemoVB.
2. C# and VB.NET
samples
See demo C# and VB.NET projects in
side directory ..\samples\UQueueTest.
3. Key design
considerations
CUQueue is designed with a set of key
considerations:
a. Easy to use. You
are never required to manage internal memory.
b. Auto-manage
memory. When you push or insert a data type into an instance of CUQueue, it will
automatically increase memory if required.
c. Highly
efficient. Use of CUQueue can avoid allocating and de-allocating memories
repeatedly, which significantly helps the performance and reduces memory resources and page
fault.
d. Great
compatibility among different development languages like VB6, VB.NET, C# and
C/C++.
4. Compatibility
among different development languages
SocketPro supports development using
different languages. For example, you can evenly develop old VB6/5 client
application that directly talks with any dotNet languages without requiring any
other middle components. To achieve this key feature, CUQueue and ATL COM UQueue
are written with the mind of compatibility among different development languages
for a set of basic data types. Here is the table about the compatibility among
four development languages, VB6, VB.Net, C# and C/C++.
| Data Type |
Size (byte) |
VB6 |
VB.Net |
C# |
JavaScript
(save/load) |
C/C++ |
| unsigned byte |
1 |
Byte |
byte |
byte |
Byte |
unsigned char |
| signed byte |
1 |
Byte |
byte |
sbyte |
Byte |
signed char |
| bool |
1 |
byte |
boolean |
bool |
Bool |
bool |
| short |
2 |
Integer |
short |
short |
Int16 |
short |
| int |
4 |
Long |
Integer |
int |
Int32 |
int |
| long |
4 |
Long |
Integer |
int |
Int32 |
long |
| float |
4 |
Single |
Single |
float |
Float |
float |
| double |
8 |
Double |
Double |
double |
Double |
double |
| unsigned short |
2 |
Integer |
short |
ushort |
Int16 |
unsigned short |
| unsigned int |
4 |
Long |
Integer |
uint |
Int32 |
unsigned int |
| unsigned long |
4 |
Long |
Integer |
uint |
Int32 |
unsigned long |
| decimal* |
16 |
|
decimal |
decimal |
Decimal |
DECIMAL |
| Currency |
8 |
Currency |
decimal |
decimal |
|
Currency |
| LONGLONG |
8 |
|
Long |
long |
Int64 |
LONGLONG |
| ULONGLONG |
8 |
|
Long |
ulong |
Int64 |
ULONGLONG |
| wide string |
|
String |
string |
string |
String |
wide string |
| variant bool |
2 |
boolean |
short |
ushort |
|
unsigned short |
| variant date |
8 |
Date |
DateTime |
DateTime |
Date (FileTime) |
double |
| wide char |
2 |
|
Char |
char |
|
wide char |
| GUID |
16 |
|
Guid |
Guid |
|
GUID |
| File Time |
8 |
|
FILETIME |
FILETIME |
|
FILETIME |
| Others* |
|
|
|
|
|
Others |
5. Native VARIANT
and dotNet object
All of data types or their array can
be boxed into object in dotNet platform, which is similar with VARIANT in the
native C/C++ development environment. CUQueue and ATL COM UQueue support
conversion between VARIANT and object with a few exceptions to the above table
as indicated with charater "*". SocketProAdapter for JavaScript
supports serialization and de-serialization of object (VARIANT) too. An object or VARAINT can contain an
array of its children, which may contain their own children. These children can
be either the same or different data types.
6. Use of dotNet
serialization within CUQueue
Dotnet version of CUQueue can take
advantage of dotNet serialization if your development is involved with managed
world only. You can call CUQueue::Serialize and Deserialize to push and
pop a managed object into and from CUQueue, respectively, with one of the two
formats, binary and XML. |