DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// Copyright (C) 2000 Stephen Cleary // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org for updates, documentation, and revision history. #ifndef BOOST_POOL_SINGLETON_HPP #define BOOST_POOL_SINGLETON_HPP // The following code might be put into some Boost.Config header in a later revision #ifdef __BORLANDC__ # pragma option push -w-inl #endif // // The following helper classes are placeholders for a generic "singleton" // class. The classes below support usage of singletons, including use in // program startup/shutdown code, AS LONG AS there is only one thread // running before main() begins, and only one thread running after main() // exits. // // This class is also limited in that it can only provide singleton usage for // classes with default constructors. // // The design of this class is somewhat twisted, but can be followed by the // calling inheritance. Let us assume that there is some user code that // calls "singleton_default
::instance()". The following (convoluted) // sequence ensures that the same function will be called before main(): // instance() contains a call to create_object.do_nothing() // Thus, object_creator is implicitly instantiated, and create_object // must exist. // Since create_object is a static member, its constructor must be // called before main(). // The constructor contains a call to instance(), thus ensuring that // instance() will be called before main(). // The first time instance() is called (i.e., before main()) is the // latest point in program execution where the object of type T // can be created. // Thus, any call to instance() will auto-magically result in a call to // instance() before main(), unless already present. // Furthermore, since the instance() function contains the object, instead // of the singleton_default class containing a static instance of the // object, that object is guaranteed to be constructed (at the latest) in // the first call to instance(). This permits calls to instance() from // static code, even if that code is called before the file-scope objects // in this file have been initialized. namespace boost { namespace details { namespace pool { // T must be: no-throw default constructible and no-throw destructible template
struct singleton_default { private: struct object_creator { // This constructor does nothing more than ensure that instance() // is called before main() begins, thus creating the static // T object before multithreading race issues can come up. object_creator() { singleton_default
::instance(); } inline void do_nothing() const { } }; static object_creator create_object; singleton_default(); public: typedef T object_type; // If, at any point (in user code), singleton_default
::instance() // is called, then the following function is instantiated. static object_type & instance() { // This is the object that we return a reference to. // It is guaranteed to be created before main() begins because of // the next line. static object_type obj; // The following line does nothing else than force the instantiation // of singleton_default
::create_object, whose constructor is // called before main() begins. create_object.do_nothing(); return obj; } }; template
typename singleton_default
::object_creator singleton_default
::create_object; } // namespace pool } // namespace details } // namespace boost // The following code might be put into some Boost.Config header in a later revision #ifdef __BORLANDC__ # pragma option pop #endif #endif
singleton.hpp
Page URL
File URL
Prev
14/14 Next
Download
( 3 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.