kodi
NptBsdBlockerSocket.h
1 /*****************************************************************
2 |
3 | Wasabi - Blocker Socket internal header
4 |
5 | $Id: NptBsdBlockerSocket.h 268 2015-05-28 19:13:46Z ehodzic $
6 | Original author: Edin Hodzic (dino@concisoft.com)
7 |
8 | This software is provided to you pursuant to your agreement
9 | with Intertrust Technologies Corporation ("Intertrust").
10 | This software may be used only in accordance with the terms
11 | of the agreement.
12 |
13 | Copyright (c) 2015 by Intertrust. All rights reserved.
14 |
15 ****************************************************************/
16 
17 #ifndef _NPT_BSD_BLOCKER_SOCKET_H_
18 #define _NPT_BSD_BLOCKER_SOCKET_H_
19 
20 /*----------------------------------------------------------------------
21 | includes
22 +---------------------------------------------------------------------*/
23 #include "NptHash.h"
24 #include "NptThreads.h"
25 
26 /*----------------------------------------------------------------------
27 | forward declaration
28 +---------------------------------------------------------------------*/
29 class NPT_BsdSocketFd;
31 
32 /*----------------------------------------------------------------------
33 | NPT_Hash<NPT_Thread::ThreadId>
34 +---------------------------------------------------------------------*/
35 template <>
36 struct NPT_Hash<NPT_Thread::ThreadId>
37 {
38  NPT_UInt32 operator()(NPT_Thread::ThreadId i) const { return NPT_Fnv1aHash32(reinterpret_cast<const NPT_UInt8*>(&i), sizeof(i)); }
39 };
40 
41 /*----------------------------------------------------------------------
42 | NPT_BlockerSocket
43 +---------------------------------------------------------------------*/
45 public:
47  Set(NPT_Thread::GetCurrentThreadId(), fd.AsPointer());
48  }
50  Set(NPT_Thread::GetCurrentThreadId(), NULL);
51  }
52 
53  static NPT_Result Cancel(NPT_Thread::ThreadId id);
54 
55 private:
56  static NPT_Result Set(NPT_Thread::ThreadId id, NPT_BsdSocketFd* fd);
57 
58  static NPT_Mutex MapLock;
60 };
61 
62 #endif // _NPT_BSD_BLOCKER_SOCKET_H_
Definition: NptThreads.h:234
T * AsPointer() const
Returns the naked pointer value.
Definition: NptReferences.h:120
Definition: NptMap.h:321
Definition: NptHash.h:55
Definition: NptThreads.h:76
Definition: NptBsdSockets.cpp:667
Definition: NptBsdBlockerSocket.h:44