Last change
on this file since 29 was
29,
checked in by landauf, 17 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.3 KB
|
Line | |
---|
1 | // (C) Copyright Mac Murrett 2001. |
---|
2 | // Use, modification and distribution are subject to the |
---|
3 | // Boost Software License, Version 1.0. (See accompanying file |
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | // See http://www.boost.org for most recent version. |
---|
7 | |
---|
8 | #include "delivery_man.hpp" |
---|
9 | |
---|
10 | #include "os.hpp" |
---|
11 | #include "execution_context.hpp" |
---|
12 | |
---|
13 | |
---|
14 | namespace boost { |
---|
15 | |
---|
16 | namespace threads { |
---|
17 | |
---|
18 | namespace mac { |
---|
19 | |
---|
20 | namespace detail { |
---|
21 | |
---|
22 | |
---|
23 | delivery_man::delivery_man(): |
---|
24 | m_pPackage(NULL), |
---|
25 | m_pSemaphore(kInvalidID), |
---|
26 | m_bPackageWaiting(false) |
---|
27 | { |
---|
28 | assert(at_st()); |
---|
29 | |
---|
30 | OSStatus lStatus = MPCreateSemaphore(1UL, 0UL, &m_pSemaphore); |
---|
31 | // TODO - throw on error here |
---|
32 | assert(lStatus == noErr); |
---|
33 | } |
---|
34 | |
---|
35 | delivery_man::~delivery_man() |
---|
36 | { |
---|
37 | assert(m_bPackageWaiting == false); |
---|
38 | |
---|
39 | OSStatus lStatus = MPDeleteSemaphore(m_pSemaphore); |
---|
40 | assert(lStatus == noErr); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | void delivery_man::accept_deliveries() |
---|
45 | { |
---|
46 | if(m_bPackageWaiting) |
---|
47 | { |
---|
48 | assert(m_pPackage != NULL); |
---|
49 | m_pPackage->accept(); |
---|
50 | m_pPackage = NULL; |
---|
51 | m_bPackageWaiting = false; |
---|
52 | |
---|
53 | // signal to the thread making the call that we're done |
---|
54 | OSStatus lStatus = MPSignalSemaphore(m_pSemaphore); |
---|
55 | assert(lStatus == noErr); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | } // namespace detail |
---|
61 | |
---|
62 | } // namespace mac |
---|
63 | |
---|
64 | } // namespace threads |
---|
65 | |
---|
66 | } // namespace boost |
---|
Note: See
TracBrowser
for help on using the repository browser.