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
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 /*----------------------------------------------------------------------
22 +---------------------------------------------------------------------*/
24 #include "NptThreads.h"
26 /*----------------------------------------------------------------------
28 +---------------------------------------------------------------------*/
29 class NPT_BsdSocketFd
;
30 typedef NPT_Reference
<NPT_BsdSocketFd
> NPT_BsdSocketFdReference
;
32 /*----------------------------------------------------------------------
33 | NPT_Hash<NPT_Thread::ThreadId>
34 +---------------------------------------------------------------------*/
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 /*----------------------------------------------------------------------
43 +---------------------------------------------------------------------*/
44 class NPT_BsdBlockerSocket
{
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
);
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_