Brief introduction about memory queue -- CUQueue and CScopeUQueue objects

Similar documents
Understand Computer Storage and Data Types

Brief introduction of SocketPro continuous SQL-stream sending and processing system (Part 1: SQLite)

Tutoral 7 Exchange any size files between client and server

Question And Answer.

Chapter 2: Using Data

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Bit (0, 1) Byte (8 bits: 0-255) Numeral systems. Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1/13/2011

pybdg Documentation Release 1.0.dev2 Outernet Inc

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

.Net Technologies. Components of.net Framework

Chapter 1 Getting Started

DAD Lab. 1 Introduc7on to C#

Defining Unified CCX CTI Messages

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Industrial Programming

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

COM & COM+ (Component Object Model) Bazsó-Dombi András, Group 251.

Appendix G: Writing Managed C++ Code for the.net Framework

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Short Notes of CS201

Visual C# Instructor s Manual Table of Contents

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CS201 - Introduction to Programming Glossary By

Basic data types. Building blocks of computation

CSSE 220 Day 8. Arrays, ArrayLists, Wrapper Classes, Auto-boxing, Enhanced for loop. Check out ArraysAndLists from SVN

Introduce C# as Object Oriented programming language. Explain, tokens,

CSSE 220. Arrays, ArrayLists, Wrapper Classes, Auto-boxing, Enhanced for loop. Check out ArraysListPractice from SVN

CCReflect has a few interesting features that are quite desirable for DigiPen game projects:

BSON C++ API. Version by Sans Pareil Technologies, Inc. Generated by Doxygen Thu Feb :32:39

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

Voyager Interoperability Guide Version 1.1 for Voyager 8.0

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

C#: framework overview and in-the-small features

Introduction to Programming Using Java (98-388)

Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz

Compiling Techniques

Programming refresher and intro to C programming

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Getting started with Java

Darshan Institute of Engineering & Technology for Diploma Studies

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

C# and Java. C# and Java are both modern object-oriented languages

Memory Based Driver PTC Inc. All Rights Reserved.

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Exercise: Using Numbers

Computer Science 9608 (Notes) Chapter: 4.1 Computational thinking and problem-solving

Data Storage and Query Answering. Data Storage and Disk Structure (4)

CS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

printf( Please enter another number: ); scanf( %d, &num2);

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

Unit 6 - Software Design and Development LESSON 4 DATA TYPES

Tutorial 8 Build resilient, responsive and scalable web applications with SocketPro

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Object Explorer. Atacama Large Millimeter Array

ESc101 : Fundamental of Computing

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Introduction to C# Applications

A NET Refresher

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

Basic Types, Variables, Literals, Constants

CS2141 Software Development using C/C++ C++ Basics

Java Basic Datatypees

COMP2611: Computer Organization. Data Representation

17. Instruction Sets: Characteristics and Functions

CMSC Introduction to Algorithms Spring 2012 Lecture 7

Programming in C++ 6. Floating point data types

Simulator Driver PTC Inc. All Rights Reserved.

Memory, Data, & Addressing II CSE 351 Spring

Computational Expression

Number Representation & Conversion

COE318 Lecture Notes Week 3 (Week of Sept 17, 2012)

IT 1033: Fundamentals of Programming Data types & variables

Lecture 1: Overview of Java

Static Imports, Default Values, Number Types and More!

Programming. Syntax and Semantics

C++ for Java Programmers

C# MOCK TEST C# MOCK TEST I

Lecture 4: Instruction Set Architecture

CSC Java Programming, Fall Java Data Types and Control Constructs

TYPES, VALUES AND DECLARATIONS

Building a Test Suite

Vive Input Utility Developer Guide

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Advanced Computer Programming

10/9/2012. Computers are machines that process data. assignment in C# Primitive Data Types. Creating and Running Your First C# Program

Advanced Systems Programming

IT 4043 Data Structures and Algorithms. Budditha Hettige Department of Computer Science

Data Types. Data Types. Introduction. Data Types. Data Types. Data Types. Introduction

PIC 20A Number, Autoboxing, and Unboxing

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

The Object Model Overview. Contents. Section Title

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Transcription:

Brief introduction about memory queue -- CUQueue and CScopeUQueue objects UDAParts support@udaparts.com Updated on Nov. 22, 2016 Contents 1. Introduction 2. C++, C#/VB.NET, Java and Python samples 3. Key design considerations on CUQueue and CScopeUQueue 4. Compatibility among different development languages 5. Object within different development languages 6. Use of.net serialization with CUQueue 7. String serialization 8. Generics Save/Load for.net and Java as well as operators <</>> in C++ 9. IUSerializer of.net, Java and Python for complex user-defined classes and structures 10. null/nothing objects serialization supported 11. Use CScopeUQueue within function stack whenever possible 1. Introduction SocketPro development requires converting different types of data into bytes at adapter level for all supported development languages. The conversion is not difficult at all, but it is considerably tedious. In order to ease SocketPro development, SocketPro provides a helper class CUQueue within each adapter of languages to efficiently pack various types of data compatibly into bytes. Later, you can effortlessly unpack requests and returned results in binary format into original types of data compatibly at both server and client sides. 2. C++, C#/VB.NET, Java and Python samples See the following demonstration applications:

Simple serialization and de-serialization: C++, C#/VB.NET, Java and Python projects at the directory../socketpro/tutorials/(cplusplus csharp vbnet java\src ce python)/uqueue_demo. Exchange of complex structure between client and server: C++, C#/VB.NET, Java and Python projects at the directory../socketpro/tutorials/(cplusplus csharp vbnet java\src ce python)/hello_world. 3. Key design considerations on CUQueue and CScopeUQueue CUQueue is designed with a set of key considerations: Easy to use. You are never required to manage internal memory directly. Auto-manage memory. When you save, push or insert a data into an instance of CUQueue, it will automatically increase memory if necessary. High efficiency. Use of CUQueue can eliminate allocating and de-allocating memories repeatedly, which significantly improves application performance and reduces memory resources and page faults. Great compatibility among different development languages such as Python, Java, VB.NET, C# and C/C++. Compatibility is guaranteed across development languages and platforms. CScopeUQueue. CScopeUQueue is created for reuse of CUQueue without repeatedly allocating memory. When an instance of CScopeUQueue is disposed or destroyed, its internal CUQueue instance will be put back into a pool of CUQueue objects for reuse. When creating an instance of CScopeUQueue, it automatically takes one from the pooled CUQueue objects if available. If there is no CUQueue object available, a new CUQueue object will be created on-the-fly. 4. Compatibility among different development languages SocketPro supports development using different languages. For example, you can even develop a C++ client application that directly accesses codes of any dotnet languages without requiring any other middle components. To achieve compatibility, the class CUQueue is written in mind of compatibility among different development languages for a set of basic data types. Here is the table for compatibility among five major development languages, Python, Java, C#, VB.NET and C/C++. Data Type Size (byte) Java.NET (C#/VB.NET) C/C++ Python unsigned byte 1 byte byte unsigned char Save/LoadByte

signed byte 1 byte sbyte signed char Save/LoadAChar bool 1 boolean bool bool Save/LoadBool short 2 short short short Save/LoadShort int 4 int int int Save/LoadInt float 4 float float float Save/LoadFloat double 8 double double double Save/LoadDouble unsigned short 2 short ushort unsigned short Save/LoadUShort unsigned int 4 int uint unsigned int Save/LoadUInt decimal 16 Java.math.BigDecimal decimal DECIMAL Save/LoadDecimal Currency 8 N/A decimal Currency N/A LONGLONG 8 long long LONGLONG Save/LoadLong ULONGLONG 8 long ulong ULONGLONG Save/LoadULong wide char 2 char char UTF16 low-endian Save/LoadChar GUID 16 Java.util.UUID Guid GUID Save/LoadUUID Date time* 8 Java.util.Date DateTime UDateTime Save/LoadDate ASCII string byte[] byte[] or sbyte[] wide string String string Object Object object std::string std::wstring or CComBSTR on win CComVaraint (win) boost::variant(linux) Save/LoadAString Save/LoadString Save/LoadObject * -- SocketPro uses a long integer (8 bytes) to represent date time across different platforms and languages. Date time can be accurate to one microsecond. 5. Object within different development languages

All data types or their array can be boxed and unboxed into and from an Object data within Java and.net platforms, which are similar to window tagvariant structure. SocketPro uses variant in boost libraries to represent the Object data type for C++ development on non-window platforms. The class CUQueue also supports one dimension array of data types listed in the above table through Object data type, including Object data type itself. 6. Use of dotnet serialization within CUQueue Dotnet version of CUQueue can take advantage of native dotnet serialization if your development is only involved with managed code. You can call methods CUQueue::Serialize and Deserialize to save and load a managed object into and from a CUQueue instance, respectively. Dotnet serialization makes the code simpler, but slower and is restricted for desktop applications and middle tiers running on.net environment only. DotNet serialization is not interoperable with non-dotnet codes. Furthermore, note that.net codes for devices do not support native.net serialization either. 7. String serialization To serialize a string, we first save a length in unsigned int (4 bytes) in bytes, and actual string context afterward in UTF16 lowendian format by calling the method Save or operator << in C++. If the length is -1 or 0xFFFFFFFF, the string is a null for Java, C++ and C#. As you can see, the class CUQueue first pops out a length in unsigned int first, and string context afterwards when loading a string from an instance of CUQueue. 8. Generics Save/Load for.net and Java as well as operators << and >> in C++ To make code simpler, SocketPro adapter for.net now uses the generics methods Save and Load for saving and reading data to or from an instance of CUQueue. Internally, the adapter will use a proper method (Save/Load for primitive data types, Save/Load for string, IUSerializer or Serialize/Deserialize for.net objects) to save or load data from generics data type. In regards to C++, you may need to override operators << and >> to save or load instances of complex user-defined structures. For simple data types or structures, adapter for C++ will automatically handle them for you correctly through templates. 9. IUSerializer of.net, Java and Python for complex user-defined classes or structures To serialize or de-serialized a complex user-defined class or structure, it is highly recommended that the class or structure be implemented with the interface IUSerializer. The implementation is very simple since you can easily make.net code and native compatible to each other. Hence, it makes code run faster than.net serialization without involvement of reflection. In addition,.net

serialization is not available to.net compact environment, but IUSerializer is fully supported on devices. To see such details, please refer to the above samples. 10. null/nothing object serialization supported At this time, Java and.net null/nothing objects serialization and de-serialization are well supported for three types of objects. A simple object containing primitive data types, string and arrays of primitive data types and string. An instance of a user-defined class or structure implemented with the interface IUSerializer. A native.net serializable object. Also, you can easily make the first two types of objects compatible with not only native code development like C/C++ but also.net compact framework. 11. Use CScopeUQueue within function stack whenever possible Whenever an instance of CScopeUQueue is disposed, its internal CUQueue will be recycled into an internal memory pool for use in the future as described in section 3 above. For example, you should use the code style below whenever possible. using (CScopeUQueue su = new CScopeUQueue()) { int n = 12345; string str = "test"; su.save(n).save(str); //The above call is equal to the below three calls //CUQueue UQueue = su.uqueue; //UQueue.Save(n); //UQueue.Save(str); //do whatever you like here... } //Internal CUQueue will be recycled into internal pool for reuse in the future here