sndthread.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. \file sndthread.h
  3. \author michael.zohner@ec-spride.de
  4. \copyright ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
  5. Copyright (C) 2019 ENCRYPTO Group, TU Darmstadt
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. ABY is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. \brief Receiver Thread Implementation
  17. */
  18. #ifndef SND_THREAD_H_
  19. #define SND_THREAD_H_
  20. #include "thread.h"
  21. #include <memory>
  22. #include <queue>
  23. class CSocket;
  24. class SndThread: public CThread {
  25. public:
  26. SndThread(CSocket* sock, CLock *glock);
  27. void stop();
  28. ~SndThread();
  29. CLock* getlock() const;
  30. void setlock(CLock *glock);
  31. void add_snd_task_start_len(uint8_t channelid, uint64_t sndbytes, uint8_t* sndbuf, uint64_t startid, uint64_t len);
  32. void add_event_snd_task_start_len(CEvent* eventcaller, uint8_t channelid, uint64_t sndbytes, uint8_t* sndbuf, uint64_t startid, uint64_t len);
  33. void add_snd_task(uint8_t channelid, uint64_t sndbytes, uint8_t* sndbuf);
  34. void add_event_snd_task(CEvent* eventcaller, uint8_t channelid, uint64_t sndbytes, uint8_t* sndbuf);
  35. void signal_end(uint8_t channelid);
  36. void kill_task();
  37. void ThreadMain();
  38. private:
  39. struct snd_task {
  40. uint8_t channelid;
  41. std::vector<uint8_t> snd_buf;
  42. CEvent* eventcaller;
  43. };
  44. void push_task(std::unique_ptr<snd_task> task);
  45. CSocket* mysock;
  46. CLock* sndlock;
  47. std::unique_ptr<CEvent> send;
  48. std::queue<std::unique_ptr<snd_task>> send_tasks;
  49. };
  50. #endif /* SND_THREAD_H_ */