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
#ifndef BOOST_THREAD_THREAD_WIN32_HPP #define BOOST_THREAD_THREAD_WIN32_HPP // 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) // (C) Copyright 2007 Anthony Williams #include
#include
#include
#include
#include
#include
#include
#include "thread_primitives.hpp" #include "thread_heap_alloc.hpp" #include
#include
#include
#include
#include
#include
#include
#include
#ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4251) #endif namespace boost { class thread_interrupted {}; namespace detail { struct thread_exit_callback_node; struct tss_data_node; struct thread_data_base { long count; detail::win32::handle_manager thread_handle; detail::win32::handle_manager interruption_handle; boost::detail::thread_exit_callback_node* thread_exit_callbacks; boost::detail::tss_data_node* tss_data; bool interruption_enabled; unsigned id; thread_data_base(): count(0),thread_handle(detail::win32::invalid_handle_value), interruption_handle(create_anonymous_event(detail::win32::manual_reset_event,detail::win32::event_initially_reset)), thread_exit_callbacks(0),tss_data(0), interruption_enabled(true), id(0) {} virtual ~thread_data_base() {} friend void intrusive_ptr_add_ref(thread_data_base * p) { BOOST_INTERLOCKED_INCREMENT(&p->count); } friend void intrusive_ptr_release(thread_data_base * p) { if(!BOOST_INTERLOCKED_DECREMENT(&p->count)) { detail::heap_delete(p); } } void interrupt() { BOOST_VERIFY(detail::win32::SetEvent(interruption_handle)!=0); } virtual void run()=0; }; typedef boost::intrusive_ptr
thread_data_ptr; struct timeout { unsigned long start; uintmax_t milliseconds; bool relative; boost::system_time abs_time; static unsigned long const max_non_infinite_wait=0xfffffffe; timeout(uintmax_t milliseconds_): start(win32::GetTickCount()), milliseconds(milliseconds_), relative(true), abs_time(boost::get_system_time()) {} timeout(boost::system_time const& abs_time_): start(win32::GetTickCount()), milliseconds(0), relative(false), abs_time(abs_time_) {} struct remaining_time { bool more; unsigned long milliseconds; remaining_time(uintmax_t remaining): more(remaining>max_non_infinite_wait), milliseconds(more?max_non_infinite_wait:(unsigned long)remaining) {} }; remaining_time remaining_milliseconds() const { if(is_sentinel()) { return remaining_time(win32::infinite); } else if(relative) { unsigned long const now=win32::GetTickCount(); unsigned long const elapsed=now-start; return remaining_time((elapsed
struct thread_data: detail::thread_data_base { F f; thread_data(F f_): f(f_) {} thread_data(detail::thread_move_t
f_): f(f_) {} void run() { f(); } }; mutable boost::mutex thread_info_mutex; detail::thread_data_ptr thread_info; static unsigned __stdcall thread_start_function(void* param); void start_thread(); explicit thread(detail::thread_data_ptr data); detail::thread_data_ptr get_thread_info() const; public: thread(); ~thread(); template
explicit thread(F f): thread_info(detail::heap_new
>(f)) { start_thread(); } template
thread(detail::thread_move_t
f): thread_info(detail::heap_new
>(f)) { start_thread(); } thread(detail::thread_move_t
x); thread& operator=(detail::thread_move_t
x); operator detail::thread_move_t
(); detail::thread_move_t
move(); void swap(thread& x); class id; id get_id() const; bool joinable() const; void join(); bool timed_join(const system_time& wait_until); template
inline bool timed_join(TimeDuration const& rel_time) { return timed_join(get_system_time()+rel_time); } void detach(); static unsigned hardware_concurrency(); typedef detail::win32::handle native_handle_type; native_handle_type native_handle(); // backwards compatibility bool operator==(const thread& other) const; bool operator!=(const thread& other) const; static void yield(); static void sleep(const system_time& xt); // extensions void interrupt(); bool interruption_requested() const; }; inline detail::thread_move_t
move(thread& x) { return x.move(); } inline detail::thread_move_t
move(detail::thread_move_t
x) { return x; } template
struct thread::thread_data
>: detail::thread_data_base { F& f; thread_data(boost::reference_wrapper
f_): f(f_) {} void run() { f(); } }; namespace this_thread { class BOOST_THREAD_DECL disable_interruption { disable_interruption(const disable_interruption&); disable_interruption& operator=(const disable_interruption&); bool interruption_was_enabled; friend class restore_interruption; public: disable_interruption(); ~disable_interruption(); }; class BOOST_THREAD_DECL restore_interruption { restore_interruption(const restore_interruption&); restore_interruption& operator=(const restore_interruption&); public: explicit restore_interruption(disable_interruption& d); ~restore_interruption(); }; thread::id BOOST_THREAD_DECL get_id(); bool BOOST_THREAD_DECL interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time); inline bool interruptible_wait(unsigned long milliseconds) { return interruptible_wait(detail::win32::invalid_handle_value,milliseconds); } void BOOST_THREAD_DECL interruption_point(); bool BOOST_THREAD_DECL interruption_enabled(); bool BOOST_THREAD_DECL interruption_requested(); void BOOST_THREAD_DECL yield(); template
void sleep(TimeDuration const& rel_time) { interruptible_wait(static_cast
(rel_time.total_milliseconds())); } } class thread::id { private: detail::thread_data_ptr thread_data; id(detail::thread_data_ptr thread_data_): thread_data(thread_data_) {} friend class thread; friend id this_thread::get_id(); public: id(): thread_data(0) {} bool operator==(const id& y) const { return thread_data==y.thread_data; } bool operator!=(const id& y) const { return thread_data!=y.thread_data; } bool operator<(const id& y) const { return thread_data
(const id& y) const { return y.thread_data
=(const id& y) const { return !(thread_data
friend std::basic_ostream
& operator<<(std::basic_ostream
& os, const id& x) { if(x.thread_data) { return os<
interrupt(); } } }; inline bool thread::operator==(const thread& other) const { return get_id()==other.get_id(); } inline bool thread::operator!=(const thread& other) const { return get_id()!=other.get_id(); } namespace detail { struct thread_exit_function_base { virtual ~thread_exit_function_base() {} virtual void operator()() const=0; }; template
struct thread_exit_function: thread_exit_function_base { F f; thread_exit_function(F f_): f(f_) {} void operator()() const { f(); } }; void add_thread_exit_function(thread_exit_function_base*); } namespace this_thread { template
void at_thread_exit(F f) { detail::thread_exit_function_base* const thread_exit_func=detail::heap_new
>(f); detail::add_thread_exit_function(thread_exit_func); } } class thread_group: private noncopyable { public: ~thread_group() { for(std::list
::iterator it=threads.begin(),end=threads.end(); it!=end; ++it) { delete *it; } } template
thread* create_thread(F threadfunc) { boost::lock_guard
guard(m); std::auto_ptr
new_thread(new thread(threadfunc)); threads.push_back(new_thread.get()); return new_thread.release(); } void add_thread(thread* thrd) { if(thrd) { boost::lock_guard
guard(m); threads.push_back(thrd); } } void remove_thread(thread* thrd) { boost::lock_guard
guard(m); std::list
::iterator const it=std::find(threads.begin(),threads.end(),thrd); if(it!=threads.end()) { threads.erase(it); } } void join_all() { boost::lock_guard
guard(m); for(std::list
::iterator it=threads.begin(),end=threads.end(); it!=end; ++it) { (*it)->join(); } } void interrupt_all() { boost::lock_guard
guard(m); for(std::list
::iterator it=threads.begin(),end=threads.end(); it!=end; ++it) { (*it)->interrupt(); } } size_t size() const { boost::lock_guard
guard(m); return threads.size(); } private: std::list
threads; mutable mutex m; }; } #ifdef BOOST_MSVC #pragma warning(pop) #endif #endif
thread.hpp
Page URL
File URL
Prev
9/12
Next
Download
( 14 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.