GithubHelp home page GithubHelp logo

copperspice / cs_signal Goto Github PK

View Code? Open in Web Editor NEW
70.0 70.0 17.0 168 KB

Thread aware Signal/Slot library

Home Page: https://www.copperspice.com/

License: Other

C++ 77.01% CMake 22.99%
copperspice cpp signals slots

cs_signal's Introduction

CopperSpice

Introduction

CopperSpice is a set of individual libraries which can be used to develop cross platform software applications in C++. It is a totally open source project released under the LGPL V2.1 license and was initially derived from the Qt framework. Over the last several years CopperSpice has completely diverged, with a goal of providing a first class GUI library to unite the C++ community.

Our motivation for developing CopperSpice was to change the fundamental design and turn the existing framework into a set of libraries for C++ developers. We are accomplishing this by leveraging modern C++ functionality, new technology, and modern tooling. CopperSpice currently requires C++17 or newer.

The libraries available in CopperSpice include:

  • CsCore
  • CsGui
  • CsMultimedia
  • CsNetwork
  • CsOpenGL
  • CsScript
  • CsSql
  • CsSvg
  • CsVulkan
  • CsWebKit
  • CsXml
  • CsXmlPatterns

There are also several open source BSD licensed libraries which are used by CopperSpice and available as stand alone libraries for anyone developing C++ applications.

  • CsCrypto
  • CsLibGuarded
  • CsPaint
  • CsPointer
  • CsSignal
  • CsString

System Requirements

To use the CopperSpice libraries a C++17 compiler and a C++17 standard library are required.

CopperSpice CMake build files are provided with the source distribution. We recommend your projects should also use CMake and Ninja for the build system.

For additional information about building from source, refer to our CopperSpice Overview Documentation or the KitchenSink demo application for sample CMake project files.

Building

The CopperSpice libraries are built using the CMake build system.

Using the CopperSpice Libraries

  • Any C++ application using CopperSpice can be built with CMake or any build system which imports CMake files
  • CopperSpice can be linked directly into any standard C++ application

Documentation

Overview

The CopperSpice Overview documentation includes information on building CopperSpice, downloading prebuilt binary files, package requirements, setting up an application which links with CopperSpice, migrating to CopperSpice, and general configuration information.

https://www.copperspice.com/docs/cs_overview/index.html

API

The API contains full class documentation and multiple tutorials for CopperSpice and is available directly on our website and from our download page.

https://www.copperspice.com/docs/cs_api/index.html

Offline

Both the CS Overview and API documentation can be downloaded for offline use. They are available in a compressed tar file or zip format.

https://download.copperspice.com/copperspice/documentation

Major Enhancements

  • Reflection
    • No Meta-Object Compiler is required for generating meta data, all references were removed
    • The functionality provided by moc was replaced with compile time templates
    • CopperSpice automatically generates meta data for processing Signals/ Slots and Introspection
    • A template class can now inherit from QObject with no restrictions on types
    • Complex data types such as QMap<QString, int> can be used for signal or slot arguments
  • Enhanced Functionality
    • CopperSpice makes extensive use of modern C++ features
      • constexpr, lambda expressions, templates, variadic templates, template variables
      • move semantics, structured bindings, tuple, decltype, SFINAE, and type traits
    • Redesigned all container classes to use the C++ standard library containers, iterators, and algorithms
    • Refactored all Mutex and Lock classes
    • CopperSpice includes a majority of the Qt 5 classes
    • Platform independent plugin system based on standard C++
    • High DPI Rendering Support
    • Redesigned pointer classes
  • Integration of CsLibGuarded
    • Used to manage shared data
  • Integration of CsSignal
    • Improved thread aware Signal/Slot delivery
    • Increased efficiency while maintaining the full Signal/Slot API
    • Deadlocks in Signal/Slot processing have been eliminated
  • Integration of CsString
    • Improved storage to properly represent Unicode strings
    • QString8 (UTF-8) and QString16 (UTF-16) classes
    • Added QStringView, QStringParser, and QRegularExpression

Presentations

Our YouTube channel contains videos about C++, graphics, build systems, CopperSpice, DoxyPress, and other topics related to software development.

https://www.youtube.com/copperspice

Links to technical presentations recorded at CppCon, CppNow, embBO++, MeetingC++, and code::dive, can be found on our presentation page.

https://www.copperspice.com/presentations.html

Authors and Key Contributors

The CS team welcomes contributors of all skill levels. When submitting a pull request please observe our Coding Style Guidelines.

https://www.copperspice.com/style_guide/source_code_style.html

  • Ansel Sermersheim
  • Barbara Geller
  • Jan Wilmans
  • Tim van Deurzen
  • Paul Bendixen
  • Peter Bindels
  • Mortaro Marcello
  • Adam Mensel
  • Robin Mills
  • Ivailo Monev
  • Adam Mensel
  • Matan Nassaw
  • Jeff Cohen
  • Daniel Pfeifer
  • Zbigniew Skowron
  • Johan Förberg
  • Dennis Menschel

License

This library is released under the LGPL V2.1 license. For more information refer to the LICENSE file provided with this project.

References

cs_signal's People

Contributors

agserm avatar bgeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cs_signal's Issues

conflict with CsLibGuarded

Both CsSignal and CsLibGuarded provide the class template rcu_guarded in the namespace libguarded: https://github.com/copperspice/cs_signal/blob/master/src/cs_rcu_guarded.h https://github.com/copperspice/cs_libguarded/blob/master/src/cs_rcu_guarded.h
This has a very high likelihood of producing ODR violation per
https://eel.is/c++draft/basic.def.odr#10.sentence-1
https://eel.is/c++draft/basic.def.odr#13.sentence-1
https://eel.is/c++draft/basic.def.odr#13.8
https://eel.is/c++draft/basic.def.odr#15
because there is no way a user of both these libraries can know if these two definitions consist of the same sequence of tokens, without brute-forcing the comparison of sources.

some possibilities:

  • make CsSignal depend on CsLibGuarded instead of duplicating its sources
  • document that both libraries cannot be used in the same program
  • document which versions of these libraries are compatible (requires fixing #15 beforehand)
  • put these classes in different namespaces or rename the classes

The same situation happens with https://github.com/copperspice/copperspice which embeds CsSignal, CsLibGuarded and CsString

Wrong target in src/signal.cmake

While compilingCsSignal on Windows, CMake complained about this:

  Cannot specify link options for target "CsCore" which is not built by this
  project.

On line 40 in src/signal.cmake it says "target_link_options(CsCore ...", not CsSignal.

Add macros to support overloaded signal names

Copperspice has the macros that allows overloaded functions to be used as signals but cs_signal is missing those functions.

Following code throws compile error in cs_signal but works as expected (with alternative macros) in copperspice.

SIGNAL_1(void added(ClassA *a)
SIGNAL_2(added, a)

SIGNAL_1(void added(ClassB *b)
SIGNAL_2(added, b)

There are some discussions (#2) that talk about supporting overloaded signals but I can't seem to find any examples of how to use it.

CMake build script

Can you provide a CMake build script for building cs_signal? I tried building them with autotool and it did succeed but I couldn't find any generated lib to link against. The only output files I got were the following -

bin/libCsSignal-0.dll
lib/licCsSignal.dll.a // This looks like the library but has the wrong extension?
lib/libCsSignal.la

Also, install should have created a "include" directory with necessary public headers which was also missing. The included autoconf doesn't have an option to build debug and release configurations.

Optionally, additional instructions/documentation on how to build these libraries for different platforms would help.

Cannot create connection to function with different exception specifier

The following will not compile due to the 'noexcept' specifier on the activate() function:

class Receiver: public CsSignal::SlotBase
{
public:
  Receiver ();
  void activate () noexcept;
};

class Sender: public CsSignal::SignalBase
{
public:
  Sender ();

  SIGNAL_1 (void send ());
  SIGNAL_2 (send);
};

int main(int argc, char *argv[])
{
  Sender transmitter;
  Receiver radio;

  connect (transmitter, &Sender::send, radio, &Receiver::activate);

  return 0;
}

with the following error:

cs_internal.h(432): error C2825: 'T': must be a class or namespace when followed by '::'
cs_signal.h(341): note: see reference to class template instantiation 'CsSignal::Internal::Bento<void (__cdecl Receiver::* )(void) noexcept>' being compiled
main.cpp(12): note: see reference to function template instantiation 'bool CsSignal::connect<Sender,Sender,,Receiver,void(__cdecl Receiver::* )(void) noexcept>(const Sender &,void (__cdecl Sender::* )(void),const Receiver &,T,CsSignal::ConnectionKind,bool)' being compiled
          with
          [
              Sender=Sender,
              Receiver=Receiver,
              T=void (__cdecl Receiver::* )(void) noexcept
          ]
cs_internal.h(432): error C2653: 'T': is not a class or namespace name
cs_internal.h(432): error C2269: cannot create a pointer or reference to a qualified function type (requires pointer-to-member)
cs_internal.h(435): error C2825: 'T': must be a class or namespace when followed by '::'
cs_internal.h(435): error C2653: 'T': is not a class or namespace name
cs_internal.h(435): error C2535: 'void CsSignal::Internal::Bento<void (__cdecl Receiver::* )(void) noexcept>::invoke_internal(const CsSignal::Internal::TeaCupAbstract *,MethodReturn (__cdecl *)(MethodArgs...)) const': member function already defined or declared
cs_internal.h(432): note: see declaration of 'CsSignal::Internal::Bento<void (__cdecl Receiver::* )(void) noexcept>::invoke_internal'

This is with CsSignal 1.2.3 and Visual Studio CE 2022.

Making the send() function noexcept does not help.

I am not sure if there is an easy solution. The 'noexcept' specification is part of the function type but I don't know if it is used for scope resolution (e.g. matching function type to function by the compiler, like const vs. non-const). Adding a copy of invoke_internal() with a noexcept specifier did not help...

Compilation error using clang-cl

I'm using visual studio 2019 with it's clang-cl:

[1/4] C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\Llvm\bin\clang-cl.exe /nologo -TP -DBUILDING_LIB_CS_SIGNAL -DCsSignal_EXPORTS -I. -I..\..\..\ -I..\..\..\src -m32 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /Zi /O2 /Ob1 /DNDEBUG -std:c++17 /showIncludes /FoCMakeFiles\CsSignal.dir\src\cs_signal.cpp.obj /FdCMakeFiles\CsSignal.dir\ -c ..\..\..\src\cs_signal.cpp FAILED: CMakeFiles/CsSignal.dir/src/cs_signal.cpp.obj C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\Llvm\bin\clang-cl.exe /nologo -TP -DBUILDING_LIB_CS_SIGNAL -DCsSignal_EXPORTS -I. -I..\..\..\ -I..\..\..\src -m32 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /Zi /O2 /Ob1 /DNDEBUG -std:c++17 /showIncludes /FoCMakeFiles\CsSignal.dir\src\cs_signal.cpp.obj /FdCMakeFiles\CsSignal.dir\ -c ..\..\..\src\cs_signal.cpp In file included from ..\..\..\src\cs_signal.cpp:19: In file included from ..\..\..\src/cs_signal.h:33: In file included from ..\..\..\src/cs_slot.h:29: C:\Users\fradd\Downloads\cs_signal-master\src\rcu_guarded.hpp(143,7): error : no matching constructor for initialization of 'libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' : m_obj(std::forward<Us>(data)...) ^ ~~~~~~~~~~~~~~~~~~~~~~ C:\Users\fradd\Downloads\cs_signal-master\src\cs_signal.h(83,22): note: in instantiation of function template specialization 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >::rcu_guarded<libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > > &>' requested here class LIB_SIG_EXPORT SignalBase ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(75,16): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'const std::allocator<CsSignal::SignalBase::ConnectStruct>' for 1st argument explicit rcu_list(const Alloc &alloc); ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(77,7): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'const libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' for 1st argument rcu_list(const rcu_list &) = delete; ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(78,7): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' for 1st argument rcu_list(rcu_list &&) = delete; ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(74,7): note: candidate constructor not viable: requires 0 arguments, but 1 was provided rcu_list(); ^ 1 error generated. [2/4] C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\Llvm\bin\clang-cl.exe /nologo -TP -DBUILDING_LIB_CS_SIGNAL -DCsSignal_EXPORTS -I. -I..\..\..\ -I..\..\..\src -m32 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /Zi /O2 /Ob1 /DNDEBUG -std:c++17 /showIncludes /FoCMakeFiles\CsSignal.dir\src\cs_slot.cpp.obj /FdCMakeFiles\CsSignal.dir\ -c ..\..\..\src\cs_slot.cpp FAILED: CMakeFiles/CsSignal.dir/src/cs_slot.cpp.obj C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\Llvm\bin\clang-cl.exe /nologo -TP -DBUILDING_LIB_CS_SIGNAL -DCsSignal_EXPORTS -I. -I..\..\..\ -I..\..\..\src -m32 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /Zi /O2 /Ob1 /DNDEBUG -std:c++17 /showIncludes /FoCMakeFiles\CsSignal.dir\src\cs_slot.cpp.obj /FdCMakeFiles\CsSignal.dir\ -c ..\..\..\src\cs_slot.cpp In file included from ..\..\..\src\cs_slot.cpp:19: In file included from ..\..\..\src/cs_signal.h:33: In file included from ..\..\..\src/cs_slot.h:29: C:\Users\fradd\Downloads\cs_signal-master\src\rcu_guarded.hpp(143,7): error : no matching constructor for initialization of 'libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' : m_obj(std::forward<Us>(data)...) ^ ~~~~~~~~~~~~~~~~~~~~~~ C:\Users\fradd\Downloads\cs_signal-master\src\cs_signal.h(83,22): note: in instantiation of function template specialization 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >::rcu_guarded<libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > > &>' requested here class LIB_SIG_EXPORT SignalBase ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(75,16): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'const std::allocator<CsSignal::SignalBase::ConnectStruct>' for 1st argument explicit rcu_list(const Alloc &alloc); ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(77,7): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'const libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' for 1st argument rcu_list(const rcu_list &) = delete; ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(78,7): note: candidate constructor not viable: no known conversion from 'libguarded::rcu_guarded<libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> > >' to 'libguarded::rcu_list<CsSignal::SignalBase::ConnectStruct, std::mutex, std::allocator<CsSignal::SignalBase::ConnectStruct> >' for 1st argument rcu_list(rcu_list &&) = delete; ^ C:\Users\fradd\Downloads\cs_signal-master\src\rcu_list.hpp(74,7): note: candidate constructor not viable: requires 0 arguments, but 1 was provided rcu_list(); ^ 1 error generated. ninja: build stopped: subcommand failed.

possible thread safety issue

Hello, I added cs_signal to my signal-slot-benchmarks project and have encountered issues trying to run the threaded portion of the benchmark. I'm not sure if the issue is solely in cs_signal or due to a bad integration on my part.

Please refer to the rework branch of signal-slot-benchmarks including my integration of cs_signal.

For reference here is the location of the sometimes encountered exception:

cs_signal

Edit: The file is cs_signal.h

Samples

Are there any samples demonstrating the usage of the API?

I intend to use it in my project and I found very little documentation on how to use or any samples demonstrating the core functionality. I tried using it and found that there are subtle differences in how it can be used with Qt application.

Some examples would help!!

reliable source download

As mentionned in #14 (comment), this project does not uses tags. It does use some kind of versionning though, as can be seen on 6add822#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20a
There is currently no documented way to download a given version of this library. This is a problem because it prevents reliable use of this library.
Some possibilities:

  • remove version numbers from cmake files, and clearly documents that it's some kind of "live at head"
  • create tags
  • host source tarballs somewhere, and document them

These repos have the same problem, but I'm not duplicating the issue: https://github.com/copperspice/cs_string, https://github.com/copperspice/cs_libguarded, https://github.com/copperspice/cs_paint

Proposal: alternative signal declaration syntax

Currently the syntax is quite ugly:

SIGNAL_1(void someSignal(int arg1, int arg2))
SIGNAL_2(someSignal, arg1, arg2)

Duplication of the signal name and argument names can't be avoided without complicated macro and even more strange syntax (like Boost::Fusion).

But the following alternative seems equivalent, but looks a bit cleaner to me:

void someSignal(int arg1, int arg2) { ACTIVATE(someSignal, arg1, arg2); }

or

void someSignal(int arg1, int arg2) ACTIVATE(someSignal, arg1, arg2)

signal 1.2.2

Current cmake file indicates 1.2.2 but there is no tag on this repository.
Do you expect to release a new version of signal at some point ?

Not compiling using VS2019

I tried to create a new project and dragging cs_signal.cpp, main.cpp and peach.cpp in.

image

1>cs_signal.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const CsSignal::SignalBase::`vftable'" (__imp_??_7SignalBase@CsSignal@@6B@) referenced in function "public: virtual __cdecl CsSignal::SignalBase::~SignalBase(void)" (??1SignalBase@CsSignal@@UEAA@XZ)
1>cs_slot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::~PendingSlot(void)" (__imp_??1PendingSlot@CsSignal@@QEAA@XZ) referenced in function "private: virtual void __cdecl CsSignal::SlotBase::queueSlot(class CsSignal::PendingSlot,enum CsSignal::ConnectionKind)" (?queueSlot@SlotBase@CsSignal@@EEAAXVPendingSlot@2@W4ConnectionKind@2@@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::~PendingSlot(void)" (__imp_??1PendingSlot@CsSignal@@QEAA@XZ)
1>peach.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::~PendingSlot(void)" (__imp_??1PendingSlot@CsSignal@@QEAA@XZ)
1>cs_slot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const CsSignal::SlotBase::`vftable'" (__imp_??_7SlotBase@CsSignal@@6B@) referenced in function "public: __cdecl CsSignal::SlotBase::SlotBase(class CsSignal::SlotBase const &)" (??0SlotBase@CsSignal@@QEAA@AEBV01@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::PendingSlot(class CsSignal::PendingSlot &&)" (__imp_??0PendingSlot@CsSignal@@QEAA@$$QEAV01@@Z) referenced in function "void __cdecl CsSignal::activate<class TestPushButton,class TestPushButton>(class TestPushButton &,void (__cdecl TestPushButton::*)(void))" (??$activate@VTestPushButton@@V1@$$V$$Z$$V@CsSignal@@YAXAEAVTestPushButton@@P81@EAAXXZ@Z)
1>peach.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::PendingSlot(class CsSignal::PendingSlot &&)" (__imp_??0PendingSlot@CsSignal@@QEAA@$$QEAV01@@Z)
1>  Hint on symbols that are defined and could potentially match:
1>    "__declspec(dllimport) public: __cdecl CsSignal::PendingSlot::PendingSlot(class CsSignal::SignalBase *,class std::unique_ptr<class CsSignal::Internal::BentoAbstract,struct std::default_delete<class CsSignal::Internal::BentoAbstract> >,class CsSignal::SlotBase *,class std::unique_ptr<class CsSignal::Internal::BentoAbstract,struct std::default_delete<class CsSignal::Internal::BentoAbstract> >,class std::unique_ptr<class CsSignal::Internal::TeaCupAbstract,struct std::default_delete<class CsSignal::Internal::TeaCupAbstract> >)" (__imp_??0PendingSlot@CsSignal@@QEAA@PEAVSignalBase@1@V?$unique_ptr@VBentoAbstract@Internal@CsSignal@@U?$default_delete@VBentoAbstract@Internal@CsSignal@@@std@@@std@@PEAVSlotBase@1@1V?$unique_ptr@VTeaCupAbstract@Internal@CsSignal@@U?$default_delete@VTeaCupAbstract@Internal@CsSignal@@@std@@@4@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl CsSignal::SignalBase::SignalBase(void)" (__imp_??0SignalBase@CsSignal@@QEAA@XZ) referenced in function "public: __cdecl TestPushButton::TestPushButton(void)" (??0TestPushButton@@QEAA@XZ)
1>peach.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class CsSignal::SlotBase * __cdecl CsSignal::PendingSlot::receiver(void)const " (__imp_?receiver@PendingSlot@CsSignal@@QEBAPEAVSlotBase@2@XZ) referenced in function "private: virtual void __cdecl Peach::queueSlot(class CsSignal::PendingSlot,enum CsSignal::ConnectionKind)" (?queueSlot@Peach@@EEAAXVPendingSlot@CsSignal@@W4ConnectionKind@3@@Z)
1>D:\project2\cs_signal\vs2019\x64\Debug\cs_signal.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "cs_signal.vcxproj" -- FAILED.

Problems using vs2019 in Release mode

Hi.

Thanks for making this project and your YouTube videos available! I appreciate your efforts!!!

I am hitting a problem with cs_signal compiled with vs2019. Everything works as expected in Debug mode. But in Release mode when signals/slots have the same signature the incorrect slot can be called. . My guess is this is due to some compiler optimization.

I made a minimalist version of my project that demonstrates the problem
https://github.com/Hurleyworks/MVC

Running in Debug you can see that each signal generated by a button press goes to the correct slot. But in Release mode, if you press the Send 1 button, for example, all 4 slots with the same signature in Model get called

-Steve

Object destruction and cross thread signal activation

I think I've found a serious bug in CsSignal. I had several program crashes before I figured out what was going on.
If we have two objects assigned to two different threads (so these two threads decide when to destroy those objects), and one object gets destroyed by its associated thread while another object emits a signal, this line of code will crash the entire program:

bool receiverInSameThread = receiver->compareThreads();

The problem here is the following: the receiver is half-destroyed and it didn't have any chance to disconnect itself in its own thread (base destructor runs last), but another thread !synchronously! tests the receiver's thread affinity and then even calls receiver->queueSlot() on that half-destroyed object.
This makes the entire activate() method not thread safe.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.