Forum Replies Created

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • in reply to: Testing a Method which runs in a thread #553170
    AvatarKevin
    Participant
        Up
        0
        Down
        ::

        For the first point, it will be started in one Thread and Working with it’s own Input and Output Queues.
        For the second point, what exactly do you mean by that? The waitDequeueNotification Function call will return a pointer(in the complete program it returns a std::unique_ptr) which i then forward to the output queue.

        in reply to: Testing a Method which runs in a thread #553168
        AvatarKevin
        Participant
            Up
            0
            Down
            ::

            Do it needs to be atomic? I only start one instance of the Balance Class as a thread.

            in reply to: Testing a Method which runs in a thread #553166
            AvatarKevin
            Participant
                Up
                0
                Down
                ::

                Maybe i simplified the code to much :D
                I added the whole class including the Test written with GoogleTest: https://godbolt.org/z/hEaT6snaM
                It is quite large because i put it all in one place.
                What i want to archive with this class is a kind of a Load Balancer.
                The General Idea is that if there are a lot of Messages in the Output Queue i want to increase the size of the workers. I do this if three times in a row the the Outputqueue Size is greater then the given Limit.
                I also reduce the Workers if the Output Queue Size is five times below the given Limit.
                The Problem in the tests are that sometimes the Tests failes because the wait time seems to be to low. Such Problems seems to be hard to debug because if i add some output printing the test never failes because as far as i can think of the program needs some time to do the output.
                In general the testcase RunDecrementsDecreasingCounterIfQueueSizeAboveLimit failes sometimes but also others are sometimes failing.
                One idea that also came to my mind was to Mock away the Queue for that i already developed the MessageQueue Interface which is kind of an Adapter to the underlying Poco::NotificationQueue class.

                in reply to: User-defined literal, overload operator #452861
                AvatarKevin
                Participant
                    Up
                    0
                    Down
                    ::

                    I tried that code in the compiler explorer but did not get an segfault.

                    https://godbolt.org/z/dExPKxebE

                    in reply to: Testing Private Parts of a shared Library #376333
                    AvatarKevin
                    Participant
                        Up
                        0
                        Down
                        ::

                        That would be great, because the article also deals with writing tests for the public part of the DLL.

                        in reply to: Testing Private Parts of a shared Library #376329
                        AvatarKevin
                        Participant
                            Up
                            0
                            Down
                            ::

                            By private part i mean that they are not exported so they are not visible to the users of the library and therefore not visible for the test. If i want to create a test executable (for example using gmock or catch2) i have to link that executable against the shared library. The Test then did not have access to those noexported Functions. I can of course include those headerfiles but the linkage will fail because it is not able to find the function definitions in the lib file.

                            On solution of course is to create the library as a static library and then link the tests against those but i’m not sure if this is a sutaible solution

                            in reply to: Sending Notification between Threads #335918
                            AvatarKevin
                            Participant
                                Up
                                0
                                Down
                                ::

                                After the files where processed the files are deleted from that directory. In the end the content of the files are send to our kafka system :)

                                in reply to: Sending Notification between Threads #331473
                                AvatarKevin
                                Participant
                                    Up
                                    0
                                    Down
                                    ::

                                    I have 2 threads that act as producer.

                                    In general they both do the same thing, collecting files and sending the content of those file to another service who acts as the consumer.

                                    The problem here is how to ensure that a file is not send twice.

                                    This could happen because when the application starts i first start the DirectoryWatcher Thread. This Thread just receives Filesystem events. It then reads the newly added File and sends the content to another service.

                                    After i started the DirectoryWatcher Thread i start the DirectoryReader Thread. This Thread iterates over the same directory. I need this thread because in that folder the files are added in a regular base. If the application stops/crashes new files are still added to that folder. To also collect those files i added the Directory Reader. It iterates over the directory collects the files and sends the content to the same service as the DirectoryWatcher.

                                    The Problem is now during the Iteration over the Directory from the DirectoryReader new files could be added to that folder. THese files are collected by the DirectoryWatcher but it could also be that the DirectoryReader sees those files and they could be processed twice.

                                    Thats why i thought about that the DirectoryWatcher Thread sends out Notifications to the DirectoryReader containing the filename of the currently added file. The DirectoryReader then checks if on of the files it iterates over are already collected by the DirectoryWatcher and ignores them. When the DirectoryReader finished its work it send out a notification to the DirectoryWatcher. The DirectoryWatcher then stops sending those Notifications because after the DirectoryReader finished iterating over the Directory it just exit and did not exists anymore.

                                    Hope this clearifys the problem. Maybe i can try to explain it on the next Q&A.

                                    in reply to: Architectural Design Suggestion #309087
                                    AvatarKevin
                                    Participant
                                        Up
                                        0
                                        Down
                                        ::

                                        Hello Rainer,

                                        i was thinking of implementing a kind of Pipes-and-Filters Architecture.

                                        The basic idea is that the InputSource collects Data from a Folder so whenever a new file is added to that folder the InputSource receives a Notification from the Filesystem. It then loads the File creates a Message Object and notifies the Balancer with that Message. The Balancer then puts the Message into a Queue where the Workers are listening. The Worker then processes the Message. It will be a constant flow of Messages. As long as Files came into the Source Directory the Files will be processed.

                                        To implement different kind of Workers i added a common Interface for those workers.

                                        My Question is now would it be better to put the Message Class, Worker Interface and Interfaces of the Observer Pattern (Subject and Observer) into the Balancer Project and let the InputSource, Worker directly depend on that Balancer Library. (First Image)

                                        Or would it be a better approach to introduce something like a Core Library where i place those Class and Interfaces? In that case the Balancer, InputSource and Worker are depend on that Core Library. (second Image).

                                        Hope this clearify some of your points.

                                        in reply to: Wrong and missing videos from week 26 #255540
                                        AvatarKevin
                                        Participant
                                            Up
                                            0
                                            Down
                                            ::

                                            Hello Rainer,

                                            i also noticed that the exercise of Week 26 on Repeated Search is missing. The video there at the moment is the exercise from the previous Section about replace.

                                            Kevin

                                            in reply to: Missing Week 25 Intro Video #115097
                                            AvatarKevin
                                            Participant
                                                Up
                                                0
                                                Down
                                                ::

                                                Oh ok sorry for that i thought this week is about the string and stringview =)

                                                I lost a little bit of the thread because of lot work going on =)

                                                in reply to: Time Measurement in Milliseconds #109228
                                                AvatarKevin
                                                Participant
                                                    Up
                                                    0
                                                    Down
                                                    ::

                                                    okay and what is the unit of the result when subtracting two timepoints from a std::chrono::steady_clock? Is it seconds?

                                                    in reply to: Observer Pattern over Library Boarders #104943
                                                    AvatarKevin
                                                    Participant
                                                        Up
                                                        0
                                                        Down
                                                        ::

                                                        Thanks for the suggestion Rainer. Is it also possible to pass a Class Method to the Adapter (instead of overloading the function call operator)?

                                                        in reply to: Klaus Iglberger C++ Software Design #104942
                                                        AvatarKevin
                                                        Participant
                                                            Up
                                                            0
                                                            Down
                                                            ::

                                                            Another Book i can recommend is the Professional C++  from Marc Gregoire. I think this is also a great book for beginners.

                                                            in reply to: Observer Pattern over Library Boarders #103909
                                                            AvatarKevin
                                                            Participant
                                                                Up
                                                                0
                                                                Down
                                                                ::

                                                                They are running in the same process

                                                              Viewing 15 posts - 1 through 15 (of 17 total)