~markwright/scalestack/zeromq

« back to all changes in this revision

Viewing changes to scalestack/common/notification.h

  • Committer: Eric Day
  • Date: 2011-01-25 20:51:51 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: eday@oddments.org-20110125205151-rlam04duepoczo9v
Moved common into kernel, other related cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Scale Stack
3
 
 *
4
 
 * Copyright 2010 Eric Day
5
 
 *
6
 
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 
 * you may not use this file except in compliance with the License.
8
 
 * You may obtain a copy of the License at
9
 
 *
10
 
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 
 *
12
 
 * Unless required by applicable law or agreed to in writing, software
13
 
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 
 * See the License for the specific language governing permissions and
16
 
 * limitations under the License.
17
 
 */
18
 
 
19
 
/**
20
 
 * @file
21
 
 * @brief Notification Declarations
22
 
 */
23
 
 
24
 
#ifndef SCALESTACK_COMMON_NOTIFICATION_H
25
 
#define SCALESTACK_COMMON_NOTIFICATION_H
26
 
 
27
 
#include <scalestack/common/macros.h>
28
 
 
29
 
namespace scalestack
30
 
{
31
 
namespace common
32
 
{
33
 
 
34
 
/**
35
 
 * This class provides a way for different threads to notify each other. This
36
 
 * uses a pipe rather than conditional thread mechanisms to be more portable.
37
 
 */
38
 
class SCALESTACK_API notification
39
 
{
40
 
public:
41
 
 
42
 
  notification(void);
43
 
 
44
 
  ~notification();
45
 
 
46
 
  /**
47
 
   * Send a notification.
48
 
   */
49
 
  void send(void);
50
 
 
51
 
  /**
52
 
   * Wait for a notification.
53
 
   */
54
 
  void wait(void);
55
 
 
56
 
private:
57
 
 
58
 
  /**
59
 
   * Don't allow copying of objects.
60
 
   */
61
 
  notification(const notification&);
62
 
 
63
 
  /**
64
 
   * Don't allow assignment of objects.
65
 
   */
66
 
  notification& operator=(const notification&);
67
 
 
68
 
  /**
69
 
   * Format an error message from errno and throw an exception.
70
 
   *
71
 
   * @param[in] prefix The prefix for the error message.
72
 
   */
73
 
  void _throw_exception(const char* prefix);
74
 
 
75
 
  int _pipe[2];
76
 
};
77
 
 
78
 
} /* namespace common */
79
 
} /* namespace scalestack */
80
 
 
81
 
#endif /* SCALESTACK_COMMON_NOTIFICATION_H */