Global Status, global immersive Status Bar

Source: Internet
Author: User

Global Status, global immersive Status Bar

Translated from global State in http://aos?k.org/en/zeromq.html

It is not ideal to use global variables in the library. A library may be loaded many times by the program, but even so, there will only be a unique global variable set.


Figure24.1: Ø MQ being used by different libraries


In Figure 24.1, The ZeroMQ library is used for both different and independent databases, and then the application uses the two libraries.

In this case, both ZeroMQ instances access the same variables, which leads to competition conditions, strange errors, and undefined behavior.

To prevent this problem, the ZeroMQ library does not have global variables. instead, the user who uses the database is responsible for explicitly creating the global status. the object that contains the global state is called context. from the user's perspective, this context looks like a working thread pool. From ZeroMQ's perspective, it is just an object that stores some global states we need. in the preceding figure, libA has its own context, and libB also has its own context. one of them will not be damaged or overwrite the other.

The lesson here is very obvious: Do not use the global status in the database. if you do this, when the database happens to be instantiated twice by the same process, the database may crash.

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.