Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / System / Bsd / NptBsdBlockerSocket.h
blob7aac6dc92e4b2cafe7a1ab1197cbde50262383e8
1 /*****************************************************************
3 | Wasabi - Blocker Socket internal header
5 | $Id: NptBsdBlockerSocket.h 268 2015-05-28 19:13:46Z ehodzic $
6 | Original author: Edin Hodzic (dino@concisoft.com)
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.
13 | Copyright (c) 2015 by Intertrust. All rights reserved.
15 ****************************************************************/
17 #ifndef _NPT_BSD_BLOCKER_SOCKET_H_
18 #define _NPT_BSD_BLOCKER_SOCKET_H_
20 /*----------------------------------------------------------------------
21 | includes
22 +---------------------------------------------------------------------*/
23 #include "NptHash.h"
24 #include "NptThreads.h"
26 /*----------------------------------------------------------------------
27 | forward declaration
28 +---------------------------------------------------------------------*/
29 class NPT_BsdSocketFd;
30 typedef NPT_Reference<NPT_BsdSocketFd> NPT_BsdSocketFdReference;
32 /*----------------------------------------------------------------------
33 | NPT_Hash<NPT_Thread::ThreadId>
34 +---------------------------------------------------------------------*/
35 template <>
36 struct NPT_Hash<NPT_Thread::ThreadId>
38 NPT_UInt32 operator()(NPT_Thread::ThreadId i) const { return NPT_Fnv1aHash32(reinterpret_cast<const NPT_UInt8*>(&i), sizeof(i)); }
41 /*----------------------------------------------------------------------
42 | NPT_BlockerSocket
43 +---------------------------------------------------------------------*/
44 class NPT_BsdBlockerSocket {
45 public:
46 NPT_BsdBlockerSocket(const NPT_BsdSocketFdReference& fd) {
47 Set(NPT_Thread::GetCurrentThreadId(), fd.AsPointer());
49 ~NPT_BsdBlockerSocket() {
50 Set(NPT_Thread::GetCurrentThreadId(), NULL);
53 static NPT_Result Cancel(NPT_Thread::ThreadId id);
55 private:
56 static NPT_Result Set(NPT_Thread::ThreadId id, NPT_BsdSocketFd* fd);
58 static NPT_Mutex MapLock;
59 static NPT_HashMap<NPT_Thread::ThreadId, NPT_BsdSocketFd*> Map;
62 #endif // _NPT_BSD_BLOCKER_SOCKET_H_