X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6214e8d5716142f199ab71730c07a6b025518cfe..7ed9cd2891d4479fa3c2b822c474e96c5f34a488:/include/wx/socket.h diff --git a/include/wx/socket.h b/include/wx/socket.h index 628605f606..35370059e7 100644 --- a/include/wx/socket.h +++ b/include/wx/socket.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: socket.h +// Name: wx/socket.h // Purpose: Socket handling classes // Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia // Modified by: @@ -95,7 +95,7 @@ enum wxSocketType // event class WXDLLIMPEXP_FWD_NET wxSocketEvent; -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_NET, wxEVT_SOCKET, wxSocketEvent) +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_NET, wxEVT_SOCKET, wxSocketEvent); // -------------------------------------------------------------------------- // wxSocketBase @@ -179,11 +179,21 @@ public: void SetNotify(wxSocketEventFlags flags); void Notify(bool notify); - // initialize/shutdown the sockets (usually called automatically) - static bool IsInitialized(); + // initialize/shutdown the sockets (done automatically so there is no need + // to call these functions usually) + // + // should always be called from the main thread only so one of the cases + // where they should indeed be called explicitly is when the first wxSocket + // object in the application is created in a different thread static bool Initialize(); static void Shutdown(); + // check if wxSocket had been already initialized + // + // notice that this function should be only called from the main thread as + // otherwise it is inherently unsafe because Initialize/Shutdown() may be + // called concurrently with it in the main thread + static bool IsInitialized(); // Implementation from now on // -------------------------- @@ -264,14 +274,11 @@ private: wxSocketEventFlags m_eventmask; // which events to notify? wxSocketEventFlags m_eventsgot; // collects events received in OnRequest() - // the initialization count, wxSocket is initialized if > 0 - static size_t m_countInit; - friend class wxSocketReadGuard; friend class wxSocketWriteGuard; - DECLARE_NO_COPY_CLASS(wxSocketBase) + wxDECLARE_NO_COPY_CLASS(wxSocketBase); DECLARE_CLASS(wxSocketBase) }; @@ -291,7 +298,7 @@ public: bool WaitForAccept(long seconds = -1, long milliseconds = 0); - DECLARE_NO_COPY_CLASS(wxSocketServer) + wxDECLARE_NO_COPY_CLASS(wxSocketServer); DECLARE_CLASS(wxSocketServer) }; @@ -330,7 +337,7 @@ private: int m_initialRecvBufferSize; int m_initialSendBufferSize; - DECLARE_NO_COPY_CLASS(wxSocketClient) + wxDECLARE_NO_COPY_CLASS(wxSocketClient); DECLARE_CLASS(wxSocketClient) }; @@ -359,7 +366,7 @@ public: */ private: - DECLARE_NO_COPY_CLASS(wxDatagramSocket) + wxDECLARE_NO_COPY_CLASS(wxDatagramSocket); DECLARE_CLASS(wxDatagramSocket) }; @@ -382,6 +389,7 @@ public: void *GetClientData() const { return m_clientData; } virtual wxEvent *Clone() const { return new wxSocketEvent(*this); } + virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_SOCKET; } public: wxSocketNotify m_event;