PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/dep/acelite/ace/WIN32_Proactor.cpp

https://github.com/chucho/FaceCore
C++ | 804 lines | 659 code | 88 blank | 57 comment | 49 complexity | a61ea1974036cb125944d332d7faf7cc MD5 | raw file
  1. // $Id: WIN32_Proactor.cpp 91286 2010-08-05 09:04:31Z johnnyw $
  2. //
  3. #include "ace/WIN32_Proactor.h"
  4. #if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_OVERLAPPED_IO)
  5. // WIN implemenatation of the Proactor.
  6. #include "ace/Log_Msg.h"
  7. #include "ace/Object_Manager.h"
  8. #include "ace/OS_NS_errno.h"
  9. #include "ace/OS_NS_unistd.h"
  10. ACE_BEGIN_VERSIONED_NAMESPACE_DECL
  11. /**
  12. * @class ACE_WIN32_Wakeup_Completion
  13. *
  14. * This is result object is used by the <end_event_loop> of the
  15. * ACE_Proactor interface to wake up all the threads blocking
  16. * for completions.
  17. */
  18. class ACE_WIN32_Wakeup_Completion : public ACE_WIN32_Asynch_Result
  19. {
  20. public:
  21. /// Constructor.
  22. ACE_WIN32_Wakeup_Completion (ACE_Handler::Proxy_Ptr &handler_proxy,
  23. const void *act = 0,
  24. ACE_HANDLE event = ACE_INVALID_HANDLE,
  25. int priority = 0,
  26. int signal_number = ACE_SIGRTMIN);
  27. /// Destructor.
  28. virtual ~ACE_WIN32_Wakeup_Completion (void);
  29. /// This method calls the <handler>'s <handle_wakeup> method.
  30. virtual void complete (size_t bytes_transferred = 0,
  31. int success = 1,
  32. const void *completion_key = 0,
  33. u_long error = 0);
  34. };
  35. ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads,
  36. bool used_with_reactor_event_loop)
  37. : completion_port_ (0),
  38. // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!!
  39. number_of_threads_ (static_cast<DWORD> (number_of_threads)),
  40. used_with_reactor_event_loop_ (used_with_reactor_event_loop)
  41. {
  42. // Create the completion port.
  43. this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE,
  44. 0,
  45. 0,
  46. this->number_of_threads_);
  47. if (this->completion_port_ == 0)
  48. ACE_ERROR ((LM_ERROR,
  49. ACE_TEXT ("%p\n"),
  50. ACE_TEXT ("CreateIoCompletionPort")));
  51. this->get_asynch_pseudo_task ().start ();
  52. }
  53. ACE_WIN32_Proactor::~ACE_WIN32_Proactor (void)
  54. {
  55. this->get_asynch_pseudo_task ().stop ();
  56. this->close ();
  57. }
  58. ACE_Asynch_Pseudo_Task &
  59. ACE_WIN32_Proactor::get_asynch_pseudo_task ()
  60. {
  61. return this->pseudo_task_;
  62. }
  63. int
  64. ACE_WIN32_Proactor::close (void)
  65. {
  66. // Close the completion port
  67. if (this->completion_port_ != 0)
  68. {
  69. // To avoid memory leaks we should delete all results from queue.
  70. for (;;)
  71. {
  72. ACE_OVERLAPPED *overlapped = 0;
  73. u_long bytes_transferred = 0;
  74. ULONG_PTR completion_key = 0;
  75. // Get the next asynchronous operation that completes
  76. BOOL res = ::GetQueuedCompletionStatus
  77. (this->completion_port_,
  78. &bytes_transferred,
  79. &completion_key,
  80. &overlapped,
  81. 0); // poll
  82. if (overlapped == 0 || res == FALSE)
  83. break;
  84. ACE_WIN32_Asynch_Result *asynch_result =
  85. (ACE_WIN32_Asynch_Result *) overlapped;
  86. delete asynch_result;
  87. }
  88. int result = ACE_OS::close (this->completion_port_);
  89. this->completion_port_ = 0;
  90. return result;
  91. }
  92. return 0;
  93. }
  94. int
  95. ACE_WIN32_Proactor::register_handle (ACE_HANDLE handle,
  96. const void *completion_key)
  97. {
  98. ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
  99. // No locking is needed here as no state changes.
  100. ACE_HANDLE cp = ::CreateIoCompletionPort (handle,
  101. this->completion_port_,
  102. comp_key,
  103. this->number_of_threads_);
  104. if (cp == 0)
  105. {
  106. ACE_OS::set_errno_to_last_error ();
  107. // If errno == ERROR_INVALID_PARAMETER, then this handle was
  108. // already registered.
  109. if (errno != ERROR_INVALID_PARAMETER)
  110. {
  111. if (ACE::debug ())
  112. {
  113. ACE_DEBUG ((LM_ERROR,
  114. ACE_TEXT ("%p\n"),
  115. ACE_TEXT ("CreateIoCompletionPort")));
  116. }
  117. return -1;
  118. }
  119. }
  120. return 0;
  121. }
  122. ACE_Asynch_Read_Stream_Impl *
  123. ACE_WIN32_Proactor::create_asynch_read_stream (void)
  124. {
  125. ACE_Asynch_Read_Stream_Impl *implementation = 0;
  126. ACE_NEW_RETURN (implementation,
  127. ACE_WIN32_Asynch_Read_Stream (this),
  128. 0);
  129. return implementation;
  130. }
  131. ACE_Asynch_Write_Stream_Impl *
  132. ACE_WIN32_Proactor::create_asynch_write_stream (void)
  133. {
  134. ACE_Asynch_Write_Stream_Impl *implementation = 0;
  135. ACE_NEW_RETURN (implementation,
  136. ACE_WIN32_Asynch_Write_Stream (this),
  137. 0);
  138. return implementation;
  139. }
  140. ACE_Asynch_Read_Dgram_Impl *
  141. ACE_WIN32_Proactor::create_asynch_read_dgram (void)
  142. {
  143. ACE_Asynch_Read_Dgram_Impl *implementation = 0;
  144. ACE_NEW_RETURN (implementation,
  145. ACE_WIN32_Asynch_Read_Dgram (this),
  146. 0);
  147. return implementation;
  148. }
  149. ACE_Asynch_Write_Dgram_Impl *
  150. ACE_WIN32_Proactor::create_asynch_write_dgram (void)
  151. {
  152. ACE_Asynch_Write_Dgram_Impl *implementation = 0;
  153. ACE_NEW_RETURN (implementation,
  154. ACE_WIN32_Asynch_Write_Dgram (this),
  155. 0);
  156. return implementation;
  157. }
  158. ACE_Asynch_Read_File_Impl *
  159. ACE_WIN32_Proactor::create_asynch_read_file (void)
  160. {
  161. ACE_Asynch_Read_File_Impl *implementation = 0;
  162. ACE_NEW_RETURN (implementation,
  163. ACE_WIN32_Asynch_Read_File (this),
  164. 0);
  165. return implementation;
  166. }
  167. ACE_Asynch_Write_File_Impl *
  168. ACE_WIN32_Proactor::create_asynch_write_file (void)
  169. {
  170. ACE_Asynch_Write_File_Impl *implementation = 0;
  171. ACE_NEW_RETURN (implementation,
  172. ACE_WIN32_Asynch_Write_File (this),
  173. 0);
  174. return implementation;
  175. }
  176. ACE_Asynch_Accept_Impl *
  177. ACE_WIN32_Proactor::create_asynch_accept (void)
  178. {
  179. ACE_Asynch_Accept_Impl *implementation = 0;
  180. ACE_NEW_RETURN (implementation,
  181. ACE_WIN32_Asynch_Accept (this),
  182. 0);
  183. return implementation;
  184. }
  185. ACE_Asynch_Connect_Impl *
  186. ACE_WIN32_Proactor::create_asynch_connect (void)
  187. {
  188. ACE_Asynch_Connect_Impl *implementation = 0;
  189. ACE_NEW_RETURN (implementation,
  190. ACE_WIN32_Asynch_Connect (this),
  191. 0);
  192. return implementation;
  193. }
  194. ACE_Asynch_Transmit_File_Impl *
  195. ACE_WIN32_Proactor::create_asynch_transmit_file (void)
  196. {
  197. ACE_Asynch_Transmit_File_Impl *implementation = 0;
  198. ACE_NEW_RETURN (implementation,
  199. ACE_WIN32_Asynch_Transmit_File (this),
  200. 0);
  201. return implementation;
  202. }
  203. ACE_Asynch_Read_Stream_Result_Impl *
  204. ACE_WIN32_Proactor::create_asynch_read_stream_result
  205. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  206. ACE_HANDLE handle,
  207. ACE_Message_Block &message_block,
  208. size_t bytes_to_read,
  209. const void* act,
  210. ACE_HANDLE event,
  211. int priority,
  212. int signal_number)
  213. {
  214. ACE_Asynch_Read_Stream_Result_Impl *implementation = 0;
  215. ACE_NEW_RETURN (implementation,
  216. ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy,
  217. handle,
  218. message_block,
  219. bytes_to_read,
  220. act,
  221. event,
  222. priority,
  223. signal_number),
  224. 0);
  225. return implementation;
  226. }
  227. ACE_Asynch_Write_Stream_Result_Impl *
  228. ACE_WIN32_Proactor::create_asynch_write_stream_result
  229. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  230. ACE_HANDLE handle,
  231. ACE_Message_Block &message_block,
  232. size_t bytes_to_write,
  233. const void* act,
  234. ACE_HANDLE event,
  235. int priority,
  236. int signal_number)
  237. {
  238. ACE_Asynch_Write_Stream_Result_Impl *implementation = 0;
  239. ACE_NEW_RETURN (implementation,
  240. ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy,
  241. handle,
  242. message_block,
  243. bytes_to_write,
  244. act,
  245. event,
  246. priority,
  247. signal_number),
  248. 0);
  249. return implementation;
  250. }
  251. ACE_Asynch_Read_File_Result_Impl *
  252. ACE_WIN32_Proactor::create_asynch_read_file_result
  253. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  254. ACE_HANDLE handle,
  255. ACE_Message_Block &message_block,
  256. size_t bytes_to_read,
  257. const void* act,
  258. u_long offset,
  259. u_long offset_high,
  260. ACE_HANDLE event,
  261. int priority,
  262. int signal_number)
  263. {
  264. ACE_Asynch_Read_File_Result_Impl *implementation = 0;
  265. ACE_NEW_RETURN (implementation,
  266. ACE_WIN32_Asynch_Read_File_Result (handler_proxy,
  267. handle,
  268. message_block,
  269. bytes_to_read,
  270. act,
  271. offset,
  272. offset_high,
  273. event,
  274. priority,
  275. signal_number),
  276. 0);
  277. return implementation;
  278. }
  279. ACE_Asynch_Write_File_Result_Impl *
  280. ACE_WIN32_Proactor::create_asynch_write_file_result
  281. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  282. ACE_HANDLE handle,
  283. ACE_Message_Block &message_block,
  284. size_t bytes_to_write,
  285. const void* act,
  286. u_long offset,
  287. u_long offset_high,
  288. ACE_HANDLE event,
  289. int priority,
  290. int signal_number)
  291. {
  292. ACE_Asynch_Write_File_Result_Impl *implementation = 0;
  293. ACE_NEW_RETURN (implementation,
  294. ACE_WIN32_Asynch_Write_File_Result (handler_proxy,
  295. handle,
  296. message_block,
  297. bytes_to_write,
  298. act,
  299. offset,
  300. offset_high,
  301. event,
  302. priority,
  303. signal_number),
  304. 0);
  305. return implementation;
  306. }
  307. ACE_Asynch_Read_Dgram_Result_Impl *
  308. ACE_WIN32_Proactor::create_asynch_read_dgram_result
  309. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  310. ACE_HANDLE handle,
  311. ACE_Message_Block *message_block,
  312. size_t bytes_to_read,
  313. int flags,
  314. int protocol_family,
  315. const void* act,
  316. ACE_HANDLE event,
  317. int priority,
  318. int signal_number)
  319. {
  320. ACE_Asynch_Read_Dgram_Result_Impl *implementation = 0;
  321. ACE_NEW_RETURN (implementation,
  322. ACE_WIN32_Asynch_Read_Dgram_Result (handler_proxy,
  323. handle,
  324. message_block,
  325. bytes_to_read,
  326. flags,
  327. protocol_family,
  328. act,
  329. event,
  330. priority,
  331. signal_number),
  332. 0);
  333. return implementation;
  334. }
  335. ACE_Asynch_Write_Dgram_Result_Impl *
  336. ACE_WIN32_Proactor::create_asynch_write_dgram_result
  337. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  338. ACE_HANDLE handle,
  339. ACE_Message_Block *message_block,
  340. size_t bytes_to_read,
  341. int flags,
  342. const void* act,
  343. ACE_HANDLE event,
  344. int priority,
  345. int signal_number)
  346. {
  347. ACE_Asynch_Write_Dgram_Result_Impl *implementation = 0;
  348. ACE_NEW_RETURN (implementation,
  349. ACE_WIN32_Asynch_Write_Dgram_Result(handler_proxy,
  350. handle,
  351. message_block,
  352. bytes_to_read,
  353. flags,
  354. act,
  355. event,
  356. priority,
  357. signal_number),
  358. 0);
  359. return implementation;
  360. }
  361. ACE_Asynch_Accept_Result_Impl *
  362. ACE_WIN32_Proactor::create_asynch_accept_result
  363. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  364. ACE_HANDLE listen_handle,
  365. ACE_HANDLE accept_handle,
  366. ACE_Message_Block &message_block,
  367. size_t bytes_to_read,
  368. const void* act,
  369. ACE_HANDLE event,
  370. int priority,
  371. int signal_number)
  372. {
  373. ACE_Asynch_Accept_Result_Impl *implementation = 0;
  374. ACE_NEW_RETURN (implementation,
  375. ACE_WIN32_Asynch_Accept_Result (handler_proxy,
  376. listen_handle,
  377. accept_handle,
  378. message_block,
  379. bytes_to_read,
  380. act,
  381. event,
  382. priority,
  383. signal_number),
  384. 0);
  385. return implementation;
  386. }
  387. ACE_Asynch_Connect_Result_Impl *
  388. ACE_WIN32_Proactor::create_asynch_connect_result
  389. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  390. ACE_HANDLE connect_handle,
  391. const void *act,
  392. ACE_HANDLE event,
  393. int priority,
  394. int signal_number)
  395. {
  396. ACE_Asynch_Connect_Result_Impl *implementation = 0;
  397. ACE_NEW_RETURN (implementation,
  398. ACE_WIN32_Asynch_Connect_Result (handler_proxy,
  399. connect_handle,
  400. act,
  401. event,
  402. priority,
  403. signal_number),
  404. 0);
  405. return implementation;
  406. }
  407. ACE_Asynch_Transmit_File_Result_Impl *
  408. ACE_WIN32_Proactor::create_asynch_transmit_file_result
  409. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  410. ACE_HANDLE socket,
  411. ACE_HANDLE file,
  412. ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
  413. size_t bytes_to_write,
  414. u_long offset,
  415. u_long offset_high,
  416. size_t bytes_per_send,
  417. u_long flags,
  418. const void *act,
  419. ACE_HANDLE event,
  420. int priority,
  421. int signal_number)
  422. {
  423. ACE_Asynch_Transmit_File_Result_Impl *implementation = 0;
  424. ACE_NEW_RETURN (implementation,
  425. ACE_WIN32_Asynch_Transmit_File_Result (handler_proxy,
  426. socket,
  427. file,
  428. header_and_trailer,
  429. bytes_to_write,
  430. offset,
  431. offset_high,
  432. bytes_per_send,
  433. flags,
  434. act,
  435. event,
  436. priority,
  437. signal_number),
  438. 0);
  439. return implementation;
  440. }
  441. ACE_Asynch_Result_Impl *
  442. ACE_WIN32_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy,
  443. const void *act,
  444. const ACE_Time_Value &tv,
  445. ACE_HANDLE event,
  446. int priority,
  447. int signal_number)
  448. {
  449. ACE_Asynch_Result_Impl *implementation = 0;
  450. ACE_NEW_RETURN (implementation,
  451. ACE_WIN32_Asynch_Timer (handler_proxy,
  452. act,
  453. tv,
  454. event,
  455. priority,
  456. signal_number),
  457. 0);
  458. return implementation;
  459. }
  460. int
  461. ACE_WIN32_Proactor::handle_signal (int, siginfo_t *, ucontext_t *)
  462. {
  463. // Perform a non-blocking "poll" for all the I/O events that have
  464. // completed in the I/O completion queue.
  465. int result = 0;
  466. for (ACE_Time_Value timeout (0, 0);
  467. ;
  468. )
  469. {
  470. result = this->handle_events (timeout);
  471. if (result != 1)
  472. break;
  473. }
  474. // If our handle_events failed, we'll report a failure to the
  475. // Reactor.
  476. return result == -1 ? -1 : 0;
  477. }
  478. int
  479. ACE_WIN32_Proactor::handle_close (ACE_HANDLE handle,
  480. ACE_Reactor_Mask close_mask)
  481. {
  482. ACE_UNUSED_ARG (close_mask);
  483. ACE_UNUSED_ARG (handle);
  484. return this->close ();
  485. }
  486. ACE_HANDLE
  487. ACE_WIN32_Proactor::get_handle (void) const
  488. {
  489. if (this->used_with_reactor_event_loop_)
  490. return this->event_.handle ();
  491. else
  492. return 0;
  493. }
  494. int
  495. ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time)
  496. {
  497. // Decrement <wait_time> with the amount of time spent in the method
  498. ACE_Countdown_Time countdown (&wait_time);
  499. return this->handle_events (wait_time.msec ());
  500. }
  501. int
  502. ACE_WIN32_Proactor::handle_events (void)
  503. {
  504. return this->handle_events (ACE_INFINITE);
  505. }
  506. int
  507. ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds)
  508. {
  509. ACE_OVERLAPPED *overlapped = 0;
  510. u_long bytes_transferred = 0;
  511. ULONG_PTR completion_key = 0;
  512. // Get the next asynchronous operation that completes
  513. BOOL result = ::GetQueuedCompletionStatus (this->completion_port_,
  514. &bytes_transferred,
  515. &completion_key,
  516. &overlapped,
  517. milli_seconds);
  518. if (result == FALSE && overlapped == 0)
  519. {
  520. ACE_OS::set_errno_to_last_error ();
  521. switch (errno)
  522. {
  523. case WAIT_TIMEOUT:
  524. errno = ETIME;
  525. return 0;
  526. case ERROR_SUCCESS:
  527. // Calling GetQueuedCompletionStatus with timeout value 0
  528. // returns FALSE with extended errno "ERROR_SUCCESS" errno =
  529. // ETIME; ?? I don't know if this has to be done !!
  530. return 0;
  531. default:
  532. if (ACE::debug ())
  533. ACE_DEBUG ((LM_ERROR,
  534. ACE_TEXT ("%p\n"),
  535. ACE_TEXT ("GetQueuedCompletionStatus")));
  536. return -1;
  537. }
  538. }
  539. else if (overlapped != 0)
  540. {
  541. // Narrow the result.
  542. ACE_WIN32_Asynch_Result *asynch_result = (ACE_WIN32_Asynch_Result *) overlapped;
  543. // If errors happen, grab the error.
  544. if (result == FALSE)
  545. ACE_OS::set_errno_to_last_error ();
  546. else
  547. errno = 0;
  548. u_long result_err = asynch_result->error ();
  549. // if "result_err" is 0 than
  550. // It is normal OS/WIN32 AIO completion.
  551. // We have cleared asynch_result->error_
  552. // during shared_read/shared_write.
  553. // The real error code is already stored in "errno",
  554. // so copy "errno" value to the "result_err"
  555. // and pass this "result_err" code
  556. // to the application_specific_code ()
  557. // else
  558. // "result_err" non zero
  559. // it means we have "post_completed" result
  560. // so pass this "result_err" code
  561. // to the application_specific_code ()
  562. if (result_err == 0)
  563. result_err = errno ;
  564. this->application_specific_code (asynch_result,
  565. static_cast<size_t> (bytes_transferred),
  566. (void *) completion_key,
  567. result_err);
  568. }
  569. return 1;
  570. }
  571. void
  572. ACE_WIN32_Proactor::application_specific_code (ACE_WIN32_Asynch_Result *asynch_result,
  573. size_t bytes_transferred,
  574. const void *completion_key,
  575. u_long error)
  576. {
  577. ACE_SEH_TRY
  578. {
  579. // Call completion hook
  580. asynch_result->complete (bytes_transferred,
  581. error ? 0 : 1,
  582. (void *) completion_key,
  583. error);
  584. }
  585. ACE_SEH_FINALLY
  586. {
  587. // This is crucial to prevent memory leaks
  588. delete asynch_result;
  589. }
  590. }
  591. int
  592. ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result)
  593. {
  594. // Grab the event associated with the Proactor
  595. HANDLE handle = this->get_handle ();
  596. // pass
  597. // bytes_transferred
  598. // completion_key
  599. // to the ::PostQueuedCompletionStatus()
  600. // error will be extracted later in handle_events()
  601. DWORD bytes_transferred = 0;
  602. const void * completion_key = 0 ;
  603. if (result != 0)
  604. {
  605. // This cast is ok since the original API calls restricted the transfer
  606. // counts to DWORD range.
  607. bytes_transferred = static_cast<DWORD> (result->bytes_transferred ());
  608. completion_key = result->completion_key();
  609. }
  610. ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
  611. // Post a completion
  612. if (::PostQueuedCompletionStatus (this->completion_port_, // completion port
  613. bytes_transferred, // xfer count
  614. comp_key, // completion key
  615. result // overlapped
  616. ) == FALSE)
  617. {
  618. delete result;
  619. if (ACE::debug ())
  620. {
  621. ACE_DEBUG ((LM_ERROR,
  622. ACE_TEXT ("%p\n"),
  623. ACE_TEXT ("PostQueuedCompletionStatus failed")));
  624. }
  625. return -1;
  626. }
  627. // If Proactor event is valid, signal it
  628. if (handle != ACE_INVALID_HANDLE
  629. && handle != 0)
  630. ACE_OS::event_signal (&handle);
  631. return 0;
  632. }
  633. int
  634. ACE_WIN32_Proactor::post_wakeup_completions (int how_many)
  635. {
  636. ACE_WIN32_Wakeup_Completion *wakeup_completion = 0;
  637. for (ssize_t ci = 0; ci < how_many; ci++)
  638. {
  639. ACE_NEW_RETURN
  640. (wakeup_completion,
  641. ACE_WIN32_Wakeup_Completion (this->wakeup_handler_.proxy ()),
  642. -1);
  643. if (wakeup_completion->post_completion (this) == -1)
  644. return -1;
  645. }
  646. return 0;
  647. }
  648. int
  649. ACE_WIN32_Proactor::wake_up_dispatch_threads (void)
  650. {
  651. return 0;
  652. }
  653. int
  654. ACE_WIN32_Proactor::close_dispatch_threads (int)
  655. {
  656. return 0;
  657. }
  658. size_t
  659. ACE_WIN32_Proactor::number_of_threads (void) const
  660. {
  661. return static_cast<size_t> (this->number_of_threads_);
  662. }
  663. void
  664. ACE_WIN32_Proactor::number_of_threads (size_t threads)
  665. {
  666. this->number_of_threads_ = static_cast<DWORD> (threads);
  667. }
  668. ACE_WIN32_Asynch_Timer::ACE_WIN32_Asynch_Timer
  669. (const ACE_Handler::Proxy_Ptr &handler_proxy,
  670. const void *act,
  671. const ACE_Time_Value &tv,
  672. ACE_HANDLE event,
  673. int priority,
  674. int signal_number)
  675. : ACE_Asynch_Result_Impl (),
  676. ACE_WIN32_Asynch_Result (handler_proxy, act, event, 0, 0, priority,
  677. signal_number),
  678. time_ (tv)
  679. {
  680. }
  681. void
  682. ACE_WIN32_Asynch_Timer::complete (size_t,
  683. int,
  684. const void *,
  685. u_long)
  686. {
  687. ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
  688. if (handler != 0)
  689. handler->handle_time_out (this->time_, this->act ());
  690. }
  691. ACE_WIN32_Wakeup_Completion::ACE_WIN32_Wakeup_Completion
  692. (ACE_Handler::Proxy_Ptr &handler_proxy,
  693. const void *act,
  694. ACE_HANDLE event,
  695. int priority,
  696. int signal_number)
  697. : ACE_Asynch_Result_Impl (),
  698. ACE_WIN32_Asynch_Result
  699. (handler_proxy, act, event, 0, 0, priority, signal_number)
  700. {
  701. }
  702. ACE_WIN32_Wakeup_Completion::~ACE_WIN32_Wakeup_Completion (void)
  703. {
  704. }
  705. void
  706. ACE_WIN32_Wakeup_Completion::complete (size_t /* bytes_transferred */,
  707. int /* success */,
  708. const void * /* completion_key */,
  709. u_long /* error */)
  710. {
  711. ACE_Handler *handler = this->handler_proxy_.get ()->handler ();
  712. if (handler != 0)
  713. handler->handle_wakeup ();
  714. }
  715. ACE_END_VERSIONED_NAMESPACE_DECL
  716. #endif /* ACE_WIN32 */