Changeset 28:9b3c2d3ea9f3 in vscpl for src
- Timestamp:
- 12/15/22 15:56:11 (2 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/hu/varadiistvan/scpl/io/_win32
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hu/varadiistvan/scpl/io/_win32/BufferedStream.cc
r9 r28 40 40 //------------------------------------------------------------------------------ 41 41 42 BufferedStream::BufferedStream(Waiter* waiter, HANDLE handle, 42 BufferedStream::BufferedStream(std::unique_ptr<EventFactory> eventFactory, 43 Waiter* waiter, HANDLE handle, 43 44 size_t readingCapacity, size_t writingCapacity) : 44 Overlappable( waiter, handle),45 Overlappable(std::move(eventFactory), waiter, handle), 45 46 readingBuffer( (readingCapacity==0) ? 0 : 46 47 new ReadingBuffer(readingCapacity, this)), -
src/hu/varadiistvan/scpl/io/_win32/BufferedStream.h
r9 r28 76 76 * Construct the buffered stream. 77 77 */ 78 BufferedStream(Waiter* waiter = 0, HANDLE handle = 0, 78 BufferedStream(std::unique_ptr<EventFactory> eventFactory, 79 Waiter* waiter = 0, HANDLE handle = 0, 79 80 size_t readingCapacity = DEFAULT_CAPACITY, 80 81 size_t writingCapacity = DEFAULT_CAPACITY); -
src/hu/varadiistvan/scpl/io/_win32/Event.h
r6 r28 133 133 inline Event::Event(EventFailable& eventFailable) : 134 134 eventFailable(eventFailable), 135 handle( CreateEvent(0, true, false, 0)),135 handle(eventFailable.createEvent()), 136 136 waiter(0) 137 137 { … … 144 144 { 145 145 removeFromWaiter(); 146 CloseHandle(handle);146 eventFailable.destroyEvent(handle); 147 147 } 148 148 … … 172 172 inline void Event::fire() 173 173 { 174 if (! SetEvent(handle)) {174 if (!eventFailable.setEvent(handle)) { 175 175 eventFailable.setErrorCode(GetLastError()); 176 176 } … … 181 181 inline bool Event::clear() 182 182 { 183 if (! ResetEvent(handle)) {183 if (!eventFailable.resetEvent(handle)) { 184 184 eventFailable.setErrorCode(GetLastError()); 185 185 return false; -
src/hu/varadiistvan/scpl/io/_win32/EventFailable.h
r6 r28 33 33 #include "../Failable.h" 34 34 35 #include "EventFactory.h" 36 37 #include <memory> 38 35 39 //------------------------------------------------------------------------------ 36 40 … … 51 55 class EventFailable : public Failable 52 56 { 57 protected: 58 /** 59 * The event factory for this object. 60 */ 61 std::unique_ptr<EventFactory> eventFactory; 62 63 protected: 64 /** 65 * Construct the object with the given event factory. 66 */ 67 EventFailable(std::unique_ptr<EventFactory> eventFactory); 68 69 /** 70 * Create an event for this object using the event factory. 71 */ 72 HANDLE createEvent(); 73 74 /** 75 * Set the event represented by the given handle using the event factory. 76 */ 77 bool setEvent(HANDLE handle); 78 79 /** 80 * Set the event represented by the given handle using the event factory. 81 */ 82 bool resetEvent(HANDLE handle); 83 84 /** 85 * Destroy the event represented by the given handle using the event factory. 86 */ 87 void destroyEvent(HANDLE handle); 88 53 89 friend class Event; 54 90 }; 91 92 //------------------------------------------------------------------------------ 93 // Inline definitions 94 //------------------------------------------------------------------------------ 95 96 inline EventFailable::EventFailable(std::unique_ptr<EventFactory> eventFactory) : 97 eventFactory(std::move(eventFactory)) 98 { 99 } 100 101 //------------------------------------------------------------------------------ 102 103 inline HANDLE EventFailable::createEvent() 104 { 105 return eventFactory->createEvent(); 106 } 107 108 //------------------------------------------------------------------------------ 109 110 inline bool EventFailable::setEvent(HANDLE handle) 111 { 112 return eventFactory->setEvent(handle); 113 } 114 115 //------------------------------------------------------------------------------ 116 117 inline bool EventFailable::resetEvent(HANDLE handle) 118 { 119 return eventFactory->resetEvent(handle); 120 } 121 122 //------------------------------------------------------------------------------ 123 124 inline void EventFailable::destroyEvent(HANDLE handle) 125 { 126 eventFactory->destroyEvent(handle); 127 } 55 128 56 129 //------------------------------------------------------------------------------ -
src/hu/varadiistvan/scpl/io/_win32/LocalServerSocketBase.h
r9 r28 83 83 84 84 inline LocalServerSocketBase::LocalServerSocketBase(Waiter* waiter) : 85 Overlappable( waiter)85 Overlappable(std::make_unique<EventFactory>(), waiter) 86 86 { 87 87 } -
src/hu/varadiistvan/scpl/io/_win32/LocalSocket.h
r14 r28 89 89 inline LocalSocket::LocalSocket(Waiter* waiter, HANDLE handle, 90 90 size_t readingCapacity, size_t writingCapacity): 91 BufferedStream(waiter, handle, readingCapacity, writingCapacity) 91 BufferedStream(std::make_unique<EventFactory>(), 92 waiter, handle, readingCapacity, writingCapacity) 92 93 { 93 94 } -
src/hu/varadiistvan/scpl/io/_win32/Makefile.am
r25 r28 7 7 libvscpl_io_win32_la_SOURCES=\ 8 8 Event.cc \ 9 EventFactory.cc \ 9 10 Overlapped.cc \ 10 11 Waiter.cc \ … … 18 19 include_vscpl_io_win32dir=$(includedir)/hu/varadiistvan/scpl/io/_win32 19 20 include_vscpl_io_win32_HEADERS=\ 21 EventFactory.h \ 20 22 EventFailable.h \ 21 23 Overlappable.h \ -
src/hu/varadiistvan/scpl/io/_win32/Overlappable.h
r9 r28 67 67 * Construct the object. 68 68 */ 69 Overlappable(Waiter* waiter = 0, HANDLE handle = 0); 69 Overlappable(std::unique_ptr<EventFactory> eventFactory, 70 Waiter* waiter = 0, HANDLE handle = 0); 70 71 71 72 public: … … 97 98 //------------------------------------------------------------------------------ 98 99 99 inline Overlappable::Overlappable(Waiter* waiter, HANDLE handle) : 100 inline Overlappable::Overlappable(std::unique_ptr<EventFactory> eventFactory, 101 Waiter* waiter, HANDLE handle) : 102 EventFailable(std::move(eventFactory)), 100 103 waiter(waiter), 101 104 handle(handle) -
src/hu/varadiistvan/scpl/io/_win32/WaitableEvent.h
r7 r28 41 41 * An event which can be waited for. 42 42 */ 43 class WaitableEvent : public Event , public EventFailable43 class WaitableEvent : public EventFailable, public Event 44 44 { 45 45 public: … … 61 61 62 62 inline WaitableEvent::WaitableEvent(Waiter* waiter) : 63 EventFailable(std::make_unique<EventFactory>()), 63 64 Event(static_cast<EventFailable&>(*this)) 64 65 {
Note:
See TracChangeset
for help on using the changeset viewer.