Rewrite of sigslot that avoids vtables.

This reduces binary size considerably and solves some other problems.

Also rewrote using variadic templates.

Initial patch contributed by andrey.semashev@gmail.com.

BUG=webrtc:2305

Review-Url: https://codereview.webrtc.org/2509733003
Cr-Commit-Position: refs/heads/master@{#16703}
This commit is contained in:
deadbeef 2017-02-19 14:12:24 -08:00 committed by Commit bot
parent 613c819dfc
commit 8d517c4170
5 changed files with 364 additions and 2540 deletions

View File

@ -12,43 +12,11 @@ namespace sigslot {
#ifdef _SIGSLOT_HAS_POSIX_THREADS
multi_threaded_global::multi_threaded_global() {
pthread_mutex_init(get_mutex(), NULL);
}
multi_threaded_global::multi_threaded_global(const multi_threaded_global&) {
}
multi_threaded_global::~multi_threaded_global() = default;
void multi_threaded_global::lock() {
pthread_mutex_lock(get_mutex());
}
void multi_threaded_global::unlock() {
pthread_mutex_unlock(get_mutex());
}
multi_threaded_local::multi_threaded_local() {
pthread_mutex_init(&m_mutex, NULL);
}
multi_threaded_local::multi_threaded_local(const multi_threaded_local&) {
pthread_mutex_init(&m_mutex, NULL);
}
multi_threaded_local::~multi_threaded_local() {
pthread_mutex_destroy(&m_mutex);
}
void multi_threaded_local::lock() {
pthread_mutex_lock(&m_mutex);
}
void multi_threaded_local::unlock() {
pthread_mutex_unlock(&m_mutex);
pthread_mutex_t* multi_threaded_global::get_mutex() {
static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
return &g_mutex;
}
#endif // _SIGSLOT_HAS_POSIX_THREADS
}; // namespace sigslot
} // namespace sigslot

File diff suppressed because it is too large Load Diff

View File

@ -103,12 +103,8 @@ class multi_threaded_local_fake : public sigslot::multi_threaded_local {
multi_threaded_local_fake() : lock_count_(0), unlock_count_(0) {
}
virtual void lock() {
++lock_count_;
}
virtual void unlock() {
++unlock_count_;
}
void lock() { ++lock_count_; }
void unlock() { ++unlock_count_; }
int lock_count() { return lock_count_; }

View File

@ -50,8 +50,8 @@ class SctpFakeDataReceiver : public sigslot::has_slots<> {
last_params_ = ReceiveDataParams();
}
virtual void OnDataReceived(const ReceiveDataParams& params,
const rtc::CopyOnWriteBuffer& data) {
void OnDataReceived(const ReceiveDataParams& params,
const rtc::CopyOnWriteBuffer& data) {
received_ = true;
last_data_ = std::string(data.data<char>(), data.size());
last_params_ = params;

View File

@ -25,7 +25,7 @@ class StunServer : public sigslot::has_slots<> {
// Creates a STUN server, which will listen on the given socket.
explicit StunServer(rtc::AsyncUDPSocket* socket);
// Removes the STUN server from the socket and deletes the socket.
~StunServer();
~StunServer() override;
protected:
// Slot for AsyncSocket.PacketRead: