comparison DEPENDENCIES/generic/include/boost/thread/win32/once.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
16 #include <boost/assert.hpp> 16 #include <boost/assert.hpp>
17 #include <boost/static_assert.hpp> 17 #include <boost/static_assert.hpp>
18 #include <boost/detail/interlocked.hpp> 18 #include <boost/detail/interlocked.hpp>
19 #include <boost/thread/win32/thread_primitives.hpp> 19 #include <boost/thread/win32/thread_primitives.hpp>
20 #include <boost/thread/win32/interlocked_read.hpp> 20 #include <boost/thread/win32/interlocked_read.hpp>
21 #include <boost/detail/no_exceptions_support.hpp> 21 #include <boost/core/no_exceptions_support.hpp>
22 #include <boost/thread/detail/move.hpp> 22 #include <boost/thread/detail/move.hpp>
23 #include <boost/thread/detail/invoke.hpp> 23 #include <boost/thread/detail/invoke.hpp>
24 24
25 #include <boost/bind.hpp> 25 #include <boost/bind.hpp>
26 26
150 { 150 {
151 if(!*mutex_name) 151 if(!*mutex_name)
152 { 152 {
153 name_once_mutex(mutex_name,flag_address); 153 name_once_mutex(mutex_name,flag_address);
154 } 154 }
155 #ifdef BOOST_NO_ANSI_APIS 155
156 return ::boost::detail::win32::CreateEventW( 156 return ::boost::detail::win32::create_event(
157 #else 157 mutex_name,
158 return ::boost::detail::win32::CreateEventA( 158 ::boost::detail::win32::manual_reset_event,
159 #endif 159 ::boost::detail::win32::event_initially_reset);
160 0,::boost::detail::win32::manual_reset_event,
161 ::boost::detail::win32::event_initially_reset,
162 mutex_name);
163 } 160 }
164 161
165 struct once_context { 162 struct once_context {
166 long const function_complete_flag_value; 163 long const function_complete_flag_value;
167 long const running_value; 164 long const running_value;
225 ::boost::detail::win32::SetEvent(ctx.event_handle); 222 ::boost::detail::win32::SetEvent(ctx.event_handle);
226 } 223 }
227 } 224 }
228 } 225 }
229 226
230 #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES 227 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
231 //#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) 228 //#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
232 inline void call_once(once_flag& flag, void (*f)()) 229 inline void call_once(once_flag& flag, void (*f)())
233 { 230 {
234 // Try for a quick win: if the procedure has already been called 231 // Try for a quick win: if the procedure has already been called
235 // just skip through: 232 // just skip through:
265 { 262 {
266 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 263 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
267 continue; 264 continue;
268 } 265 }
269 } 266 }
270 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 267 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
271 ctx.event_handle,::boost::detail::win32::infinite)); 268 ctx.event_handle,::boost::detail::win32::infinite, 0));
272 } 269 }
273 } 270 }
274 //#endif 271 //#endif
275 template<typename Function> 272 template<typename Function>
276 inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f) 273 inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f)
309 { 306 {
310 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 307 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
311 continue; 308 continue;
312 } 309 }
313 } 310 }
314 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 311 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
315 ctx.event_handle,::boost::detail::win32::infinite)); 312 ctx.event_handle,::boost::detail::win32::infinite,0));
316 } 313 }
317 } 314 }
318 template<typename Function, class A, class ...ArgTypes> 315 template<typename Function, class A, class ...ArgTypes>
319 inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(A) a, BOOST_THREAD_RV_REF(ArgTypes)... args) 316 inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(A) a, BOOST_THREAD_RV_REF(ArgTypes)... args)
320 { 317 {
356 { 353 {
357 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 354 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
358 continue; 355 continue;
359 } 356 }
360 } 357 }
361 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 358 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
362 ctx.event_handle,::boost::detail::win32::infinite)); 359 ctx.event_handle,::boost::detail::win32::infinite,0));
363 } 360 }
364 } 361 }
365 #else 362 #else
366 #if ! defined(BOOST_MSVC) && ! defined(BOOST_INTEL) 363 #if ! defined(BOOST_MSVC) && ! defined(BOOST_INTEL)
367 template<typename Function> 364 template<typename Function>
401 { 398 {
402 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 399 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
403 continue; 400 continue;
404 } 401 }
405 } 402 }
406 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 403 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
407 ctx.event_handle,::boost::detail::win32::infinite)); 404 ctx.event_handle,::boost::detail::win32::infinite,0));
408 } 405 }
409 } 406 }
410 template<typename Function, typename T1> 407 template<typename Function, typename T1>
411 void call_once(once_flag& flag,Function f, T1 p1) 408 void call_once(once_flag& flag,Function f, T1 p1)
412 { 409 {
444 { 441 {
445 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 442 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
446 continue; 443 continue;
447 } 444 }
448 } 445 }
449 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 446 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
450 ctx.event_handle,::boost::detail::win32::infinite)); 447 ctx.event_handle,::boost::detail::win32::infinite,0));
451 } 448 }
452 } 449 }
453 template<typename Function, typename T1, typename T2> 450 template<typename Function, typename T1, typename T2>
454 void call_once(once_flag& flag,Function f, T1 p1, T2 p2) 451 void call_once(once_flag& flag,Function f, T1 p1, T2 p2)
455 { 452 {
487 { 484 {
488 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 485 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
489 continue; 486 continue;
490 } 487 }
491 } 488 }
492 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 489 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
493 ctx.event_handle,::boost::detail::win32::infinite)); 490 ctx.event_handle,::boost::detail::win32::infinite,0));
494 } 491 }
495 } 492 }
496 template<typename Function, typename T1, typename T2, typename T3> 493 template<typename Function, typename T1, typename T2, typename T3>
497 void call_once(once_flag& flag,Function f, T1 p1, T2 p2, T3 p3) 494 void call_once(once_flag& flag,Function f, T1 p1, T2 p2, T3 p3)
498 { 495 {
530 { 527 {
531 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 528 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
532 continue; 529 continue;
533 } 530 }
534 } 531 }
535 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 532 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
536 ctx.event_handle,::boost::detail::win32::infinite)); 533 ctx.event_handle,::boost::detail::win32::infinite,0));
537 } 534 }
538 } 535 }
539 #elif defined BOOST_NO_CXX11_RVALUE_REFERENCES 536 #elif defined BOOST_NO_CXX11_RVALUE_REFERENCES
540 537
541 template<typename Function> 538 template<typename Function>
575 { 572 {
576 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 573 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
577 continue; 574 continue;
578 } 575 }
579 } 576 }
580 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 577 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
581 ctx.event_handle,::boost::detail::win32::infinite)); 578 ctx.event_handle,::boost::detail::win32::infinite,0));
582 } 579 }
583 } 580 }
584 template<typename Function, typename T1> 581 template<typename Function, typename T1>
585 void call_once(once_flag& flag,Function const&f, T1 const&p1) 582 void call_once(once_flag& flag,Function const&f, T1 const&p1)
586 { 583 {
618 { 615 {
619 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 616 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
620 continue; 617 continue;
621 } 618 }
622 } 619 }
623 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 620 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
624 ctx.event_handle,::boost::detail::win32::infinite)); 621 ctx.event_handle,::boost::detail::win32::infinite,0));
625 } 622 }
626 } 623 }
627 template<typename Function, typename T1, typename T2> 624 template<typename Function, typename T1, typename T2>
628 void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2) 625 void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2)
629 { 626 {
661 { 658 {
662 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 659 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
663 continue; 660 continue;
664 } 661 }
665 } 662 }
666 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 663 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
667 ctx.event_handle,::boost::detail::win32::infinite)); 664 ctx.event_handle,::boost::detail::win32::infinite,0));
668 } 665 }
669 } 666 }
670 template<typename Function, typename T1, typename T2, typename T3> 667 template<typename Function, typename T1, typename T2, typename T3>
671 void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2, T3 const&p3) 668 void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2, T3 const&p3)
672 { 669 {
704 { 701 {
705 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 702 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
706 continue; 703 continue;
707 } 704 }
708 } 705 }
709 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 706 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
710 ctx.event_handle,::boost::detail::win32::infinite)); 707 ctx.event_handle,::boost::detail::win32::infinite,0));
711 } 708 }
712 } 709 }
713 #endif 710 #endif
714 #if 1 711 #if 1
715 #if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) 712 #if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
749 { 746 {
750 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 747 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
751 continue; 748 continue;
752 } 749 }
753 } 750 }
754 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 751 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
755 ctx.event_handle,::boost::detail::win32::infinite)); 752 ctx.event_handle,::boost::detail::win32::infinite,0));
756 } 753 }
757 } 754 }
758 template<typename T1> 755 template<typename T1>
759 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1)), BOOST_THREAD_RV_REF(T1) p1) 756 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1)), BOOST_THREAD_RV_REF(T1) p1)
760 { 757 {
794 { 791 {
795 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 792 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
796 continue; 793 continue;
797 } 794 }
798 } 795 }
799 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 796 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
800 ctx.event_handle,::boost::detail::win32::infinite)); 797 ctx.event_handle,::boost::detail::win32::infinite,0));
801 } 798 }
802 } 799 }
803 template<typename Function, typename T1, typename T2> 800 template<typename Function, typename T1, typename T2>
804 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) 801 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2)
805 { 802 {
840 { 837 {
841 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 838 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
842 continue; 839 continue;
843 } 840 }
844 } 841 }
845 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 842 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
846 ctx.event_handle,::boost::detail::win32::infinite)); 843 ctx.event_handle,::boost::detail::win32::infinite,0));
847 } 844 }
848 } 845 }
849 template<typename Function, typename T1, typename T2, typename T3> 846 template<typename Function, typename T1, typename T2, typename T3>
850 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) 847 void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3)
851 { 848 {
887 { 884 {
888 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 885 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
889 continue; 886 continue;
890 } 887 }
891 } 888 }
892 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 889 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
893 ctx.event_handle,::boost::detail::win32::infinite)); 890 ctx.event_handle,::boost::detail::win32::infinite,0));
894 } 891 }
895 } 892 }
896 #endif 893 #endif
897 template<typename Function> 894 template<typename Function>
898 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f) 895 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f)
931 { 928 {
932 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 929 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
933 continue; 930 continue;
934 } 931 }
935 } 932 }
936 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 933 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
937 ctx.event_handle,::boost::detail::win32::infinite)); 934 ctx.event_handle,::boost::detail::win32::infinite,0));
938 } 935 }
939 } 936 }
940 937
941 template<typename Function, typename T1> 938 template<typename Function, typename T1>
942 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) 939 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1)
978 { 975 {
979 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 976 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
980 continue; 977 continue;
981 } 978 }
982 } 979 }
983 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 980 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
984 ctx.event_handle,::boost::detail::win32::infinite)); 981 ctx.event_handle,::boost::detail::win32::infinite,0));
985 } 982 }
986 } 983 }
987 template<typename Function, typename T1, typename T2> 984 template<typename Function, typename T1, typename T2>
988 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) 985 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2)
989 { 986 {
1025 { 1022 {
1026 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 1023 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
1027 continue; 1024 continue;
1028 } 1025 }
1029 } 1026 }
1030 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 1027 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
1031 ctx.event_handle,::boost::detail::win32::infinite)); 1028 ctx.event_handle,::boost::detail::win32::infinite,0));
1032 } 1029 }
1033 } 1030 }
1034 template<typename Function, typename T1, typename T2, typename T3> 1031 template<typename Function, typename T1, typename T2, typename T3>
1035 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) 1032 void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3)
1036 { 1033 {
1074 { 1071 {
1075 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); 1072 ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag);
1076 continue; 1073 continue;
1077 } 1074 }
1078 } 1075 }
1079 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( 1076 BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx(
1080 ctx.event_handle,::boost::detail::win32::infinite)); 1077 ctx.event_handle,::boost::detail::win32::infinite,0));
1081 } 1078 }
1082 } 1079 }
1083 1080
1084 #endif 1081 #endif
1085 #endif 1082 #endif