gPTP Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IPCListener.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 
3 Copyright (c) 2009-2012, Intel Corporation
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8 
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31 
32 ******************************************************************************/
33 
34 #ifndef IPCLISTENER_HPP
35 #define IPCLISTENER_HPP
36 
37 #include <stdlib.h>
38 #include <ipcdef.hpp>
39 #include <PeerList.hpp>
40 #include <Stoppable.hpp>
41 
47 class LockableOffset : public Lockable, public Offset {
48 private:
49  bool ready;
50 public:
55  ml_phoffset = 0;
56  ml_freqoffset = 0.0;
57  ls_phoffset = 0;
58  ls_freqoffset = 0.0;
59  local_time = 0;
60  }
65  bool isReady() { return ready; }
70  void setReady( bool ready ) { this->ready = ready; }
71 };
72 
77 public:
80 };
81 
85 class IPCListener : public Stoppable {
86 private:
87  static DWORD WINAPI IPCListenerLoopWrap( LPVOID arg ) {
88  DWORD ret;
89  LPVOID *argl = (LPVOID *) arg;
90  IPCListener *this0 = (IPCListener *) argl[0];
91  ret = this0->IPCListenerLoop((IPCSharedData *) argl[1] );
92  delete argl[1];
93  delete [] argl;
94  return ret;
95  }
96  DWORD WINAPI IPCListenerLoop( IPCSharedData *arg );
97 public:
102  bool start( IPCSharedData data ) {
103  LPVOID *arg = new LPVOID[2];
104  if( thread != NULL ) {
105  return false;
106  }
107  arg[1] = (void *) malloc((size_t) sizeof(IPCSharedData));
108  arg[0] = this;
109  *((IPCSharedData *) arg[1]) = data;
110  thread = CreateThread( NULL, 0, &IPCListenerLoopWrap, arg, 0, NULL );
111  if( thread != NULL ) return true;
112  else return false;
113  }
118 };
119 
120 
121 
122 #endif/*IPCListener_hpp*/
PeerList * list
Definition: IPCListener.hpp:78
HANDLE thread
Definition: Stoppable.hpp:48
Definition: Lockable.hpp:44
LockableOffset()
Definition: IPCListener.hpp:54
void setReady(bool ready)
Sets ready flag.
Definition: IPCListener.hpp:70
Definition: Stoppable.hpp:45
FrequencyRatio ls_freqoffset
Definition: windows/daemon_cl/ipcdef.hpp:178
bool start(IPCSharedData data)
Starts the listener loop in a new thread.
Definition: IPCListener.hpp:102
int64_t ml_phoffset
Definition: windows/daemon_cl/ipcdef.hpp:175
FrequencyRatio ml_freqoffset
Definition: windows/daemon_cl/ipcdef.hpp:176
bool isReady()
Get Internal ready flag.
Definition: IPCListener.hpp:65
uint64_t local_time
Definition: windows/daemon_cl/ipcdef.hpp:179
LockableOffset * offset
Definition: IPCListener.hpp:79
Definition: IPCListener.hpp:76
Definition: PeerList.hpp:68
~IPCListener()
Definition: IPCListener.hpp:117
Definition: IPCListener.hpp:47
Definition: IPCListener.hpp:85
int64_t ls_phoffset
Definition: windows/daemon_cl/ipcdef.hpp:177
Definition: windows/daemon_cl/ipcdef.hpp:173