SendToThread.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __SENDTO_THREAD
  11. #define __SENDTO_THREAD
  12. #include "RakNetDefines.h"
  13. #ifdef USE_THREADED_SEND
  14. #include "InternalPacket.h"
  15. #include "SocketLayer.h"
  16. #include "DS_ThreadsafeAllocatingQueue.h"
  17. #include "ThreadPool.h"
  18. namespace RakNet
  19. {
  20. class SendToThread
  21. {
  22. public:
  23. SendToThread();
  24. ~SendToThread();
  25. struct SendToThreadBlock
  26. {
  27. SOCKET s;
  28. SystemAddress systemAddress;
  29. unsigned short remotePortRakNetWasStartedOn_PS3;
  30. unsigned int extraSocketOptions;
  31. char data[MAXIMUM_MTU_SIZE];
  32. unsigned short dataWriteOffset;
  33. };
  34. static SendToThreadBlock* AllocateBlock(void);
  35. static void ProcessBlock(SendToThreadBlock* threadedSend);
  36. static void AddRef(void);
  37. static void Deref(void);
  38. static DataStructures::ThreadsafeAllocatingQueue<SendToThreadBlock> objectQueue;
  39. protected:
  40. static int refCount;
  41. static ThreadPool<SendToThreadBlock*,SendToThreadBlock*> threadPool;
  42. };
  43. }
  44. #endif
  45. #endif
粤ICP备19079148号