summaryrefslogtreecommitdiff
path: root/src/WebRTCLibPeerConnection.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-04 14:18:10 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-09 00:53:15 +0200
commit00ac03c8e7a96657de5b537cfc0396509546374e (patch)
treef5b1bbf370f17c1ab2064c6b2e79147bbecda98c /src/WebRTCLibPeerConnection.cpp
parentfa5296a4e428d625351082d13248f7f7c20f0598 (diff)
downloadfork-godot-webrtc-native-00ac03c8e7a96657de5b537cfc0396509546374e.tar.gz
fork-godot-webrtc-native-00ac03c8e7a96657de5b537cfc0396509546374e.tar.bz2
fork-godot-webrtc-native-00ac03c8e7a96657de5b537cfc0396509546374e.zip
Use a class instead of lambdas for signals.
Diffstat (limited to 'src/WebRTCLibPeerConnection.cpp')
-rw-r--r--src/WebRTCLibPeerConnection.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp
index d95b1e6..4b83ae6 100644
--- a/src/WebRTCLibPeerConnection.cpp
+++ b/src/WebRTCLibPeerConnection.cpp
@@ -174,14 +174,12 @@ godot_error WebRTCLibPeerConnection::add_ice_candidate(const char *sdpMidName, i
godot_error WebRTCLibPeerConnection::poll() {
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
- std::function<void()> signal;
while (!signal_queue.empty()) {
mutex_signal_queue->lock();
- signal = signal_queue.front();
+ Signal signal = signal_queue.front();
signal_queue.pop();
mutex_signal_queue->unlock();
-
- signal();
+ signal.emit(this);
}
return GODOT_OK;
}
@@ -244,15 +242,7 @@ WebRTCLibPeerConnection::~WebRTCLibPeerConnection() {
void WebRTCLibPeerConnection::queue_signal(godot::String p_name, int p_argc, const godot::Variant &p_arg1, const godot::Variant &p_arg2, const godot::Variant &p_arg3) {
mutex_signal_queue->lock();
- signal_queue.push(
- [this, p_name, p_argc, p_arg1, p_arg2, p_arg3] {
- if (p_argc == 1) {
- emit_signal(p_name, p_arg1);
- } else if (p_argc == 2) {
- emit_signal(p_name, p_arg1, p_arg2);
- } else {
- emit_signal(p_name, p_arg1, p_arg2, p_arg3);
- }
- });
+ const godot::Variant argv[3] = { p_arg1, p_arg2, p_arg3 };
+ signal_queue.push(Signal(p_name, p_argc, argv));
mutex_signal_queue->unlock();
}