Update and sort out the code and tools (C ++, 2014.09) provided in all my blog posts, blog 2014.09

Source: Internet
Author: User

Update and sort out the code and tools (C ++, 2014.09) provided in all my blog posts, blog 2014.09

To facilitate the management of various code and tool resources involved in the blog, you can now migrate these resources to GitHub. If you are interested, you can download them.

C ++

1. General high-performance Windows Socket component HP-Socket v3.2.3 officially released

IOCP-based general asynchronous Windows Socket TCP high-performance Server Component Design and Implementation

General asynchronous Windows Socket TCP client component design and implementation

Abstract: writing a Windows Socket TCP client is not difficult. Windows provides six I/O communication models for you to choose from. However, I have seen many client programs mix the Socket communication and business logic, and the logic is still messy. Every program can Copy/Parse similar code and then modify it. Therefore, this module uses some leisure time to write a general asynchronous Windows Socket TCP high-performance server component based on IOCP and a general asynchronous Windows Socket TCP client component for you to see the detailed parameters, I hope to inspire everyone.

HP-Socket is a set of common high-performance TCP/UDP Communication frameworks, including server components, client components, and Agent components. It is widely used in TCP/UDP communication systems in various application scenarios, provides C/C ++, C #, Delphi, E (easy language), Java, Python, and other programming language interfaces. HP-Socket fully encapsulates the communication layer, and applications do not have to pay attention to any details of the communication layer. HP-Socket provides an API Interface Based on The Event Notification model, it can be easily and efficiently integrated into new and old applications.

In order to allow users to easily and quickly learn and use HP-Socket and quickly master the design ideas and usage methods of the framework, a large number of Demo examples (such: PUSH model examples, PULL model examples, Performance Testing examples, and other programming language examples ). HP-Socket is currently running on Windows and will be supported across platforms in the future.

Resource: Visit the project homepage ^ _*

 

2. Windows C ++ general application log component (download of components and test programs)

Abstract: writing a common log component should focus on three aspects: functionality, availability, and performance. The following describes in detail the considerations for these issues when designing log components:

  • Function: This log component is designed to meet the logging requirements of most applications. It outputs logs to files or sends them to applications, and does not provide complex but uncommon functions.
  • Availability: This log component focuses on availability and makes it easy to use.
  • Performance: performance is a hard indicator of whether the component is worth using. The performance optimization should be considered during the process from design to coding.

Resource: Visit the project homepage ^ _*

 

3. How to develop good C ++ programming habits (1)-memory management

Abstract: C/C ++ Memory management seems daunting. The full screen new/delete/malloc/free and OutPut Window endless Memory Leak warnings, the strange 0X00000004 pointer of the program is abnormal. It seems that we were crying together that year. Can you Hold it? In fact, the reality is not as bad as you think. As long as you give a little bit of attention, it's right! Just a little bit --Encapsulate memory access with C ++ classIt will solve most of your troubles and benefit you for life. Taking Windows as an example, there are several main memory management methods:

  • Virtual Memory(Virtual Memory)
  • Default heapAndPrivate heap(Process Heap & Private Heap)
  • Memory ing File(File Mapping)
  • Process stack(Heap, in fact, uses malloc () or the default new operator to cut meat in a small part of Process Heap. ^_^)
  • Stack(Stack, the memory is automatically managed by the caller or by the caller)

Resource: https://github.com/ldcsaa/vc-common-src (source code in the Common/Src directory)

 

4. Message ing macro for Win32 programs (similar to MFC)

Abstract: For message ing macros, you don't need to talk about it. People who have used MFC are very clear about it. However, there are many programs that haven't used MFC for various reasons, so this post will discuss how to implement message ing macros similar to MFC in Win32 programs. In fact, the Windows header file "WindowsX. h" (Note: it is not "Windows. h") provides some useful macros to help us implement message ing. This module also implements message ing based on this header file.

Resource: https://github.com/ldcsaa/vc-common-src (source code in the Common/Src/Win32Helper. h file)

 

5. Use macro to implement the C ++ Singleton Model

Abstract: The Singleton design mode is widely used and easy to implement. It is nothing more than private several constructors, the "operator =" operator, and a static creation and destruction method. However, writing the same code for each class is intolerable for this module. Therefore, this module uses macros to encapsulate the entire Singleton mode, whether it is the definition of a class or the use of a class is extremely simple.

Resource: https://github.com/ldcsaa/vc-common-src (source code is in the Common/Src/Singleton. h file)

 

6. C ++ Private Heap

Abstract: Private Heap is a memory mechanism provided by Windows. For applications that require frequent allocation and release of dynamic memory, Private Heap is a magic weapon to Improve the Performance of applications, using it can reduce the competition for new/malloc call queues and memory holes.

Resource: https://github.com/ldcsaa/vc-common-src (source code is in the Common/Src/PrivateHeap. h file)

 

7. Windows program memory leakage detection tool based on crt debug

Abstract: Windows program memory leak detection is a very important task. GUI-based applications usually have a memory leak report at the end of debugging, but this report is not comprehensive, the specific row number that generates the leak cannot be located. In fact, implementing a memory leak detection tool by yourself is very simple, but I have read many examples written on the Internet and there are two common problems:

  • Either it is not comprehensive, it can be used in one environment, but it cannot work well in another environment, or the vulnerability report output method is unreasonable.
  • It is either too conservative, for example: there is no need to do so in _ malloc_dbg () and _ free_dbg () use the CriticalSection before and after the call (tracking the new and malloc code in a multi-threaded environment will understand ).

Resource: https://github.com/ldcsaa/vc-common-src (source code in the Common/Src/debug/win32_crtdbg.h file)




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.