Read fastdelegate and sigslot

Source: Internet
Author: User

From SourceForge and codeproject

The Running Method of sigslot is easy to understand. It is to save the object pointer and function pointer to the connection table, and then obtain and execute it when calling it.

Fastdelegate was confused by reading his documents. After reading the documents, he didn't figure out why the author said it was so fast and fast, but the memory consumption actually reduced.

Because he performs complex operations on the this pointer of all the virtual functions and multi-inheritance functions to obtain the actual address, it takes only 8 bytes for his bind at a time.

However, in addition to the memory, it is not found to be faster than sigslot.

Http://sigslot.sourceforge.net/

Http://www.codeproject.com/KB/cpp/FastDelegate.aspx

It is really a headache to use more templates, and debugging will be very tiring.

 

FastdelegateAlgorithmThe exception is complicated. He encapsulates common functions and static functions into a class through a horrible_cast, which makes him dizzy.

I have done a lot of work in pursuit of such memory.

Forced type conversion can be performed based on different types of function pointers. The begin_message_map method of MFC also adopts this method. With this kill tool, fastdelegate can be implemented.

Float test3 (int n, char * P)
{
Return N;
}

Typedef float (* myfuncptr) (INT, char *);
Myfuncptr my_func_ptr = & test3;

Float n = my_func_ptr (1, 0 );
Typedef float (* myfuncptr2) (INT );
Myfuncptr2 PTS = (myfuncptr2) my_func_ptr;
N = PTS (21 );

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.