Viewing data in a circular buffer in real time

I have an incoming message flow and require a window that allows the user to scroll through the messages.

This is my current thinking:

  • Incoming messages go into a single queue of one manufacturer.
  • The stream reads them and places them in a circular buffer with a serial id
  • That way I could safely place multiple incoming streams in a ring buffer and separate the input
  • Mutex to coordinate circular access buffer between user interface and stream
  • Two notifications from the stream to the user interface for the first id and one for the last id in the buffer when they ever change.
  • This allows the user interface to determine that it can display which parts of the circular buffer it needs, to delete overwritten messages. It gets access only to the messages necessary to fill the window with the current size and scrolling.

I am not happy with the notification in the user interface. It will be generated with high frequency. They can be queued or otherwise throttled; latency should not affect the first identifier, but delays in processing the last identifier can cause problems in cases such as viewing the very end of the full buffer, if the user interface does not make a copy of the displayed messages, which I would like to avoid.

Does this sound like the right approach? Any settings that might make it more enjoyable?

+1
2

(. Effo EDIT , ) , .

, UI .

, UI.Q . . , : , - , ( UI.Q C/++).

, UI.Q , . , posix. posix, . . , . , , , .

. , .

. EffoNetMsg.pdf http://code.google.com/p/effonetmsg/downloads/list, , .


Effo EDIT @2009oct23: , , .

                         +---------------+ 
                     +---> Ring Buffer-1 <---+
                     |   +---------------+   |
                  +--+                       +-----+
                  |  |   +---------------+   |     |
                  |  +---> Ring Buffer-2 <---+     |
                  |      +---------------+         |
                  |                                |
          +-------+-------+            +-----------+----------+
          |   Push Msg &  |            |   GetHeadTail()      |
          |  Send AckReq  |            |  & Send UpdateReq    |
          +---------------+            +----------------------+
          |App.MsgStage() |            |   App.DisPlayStage() |
          +-------+-------+            +-----------+----------+
                  | Pop()                          | Pop()         
 ^              +-V-+                            +-V-+ 
 | Events       | Q |    Msg Stage |             | Q |  Display Stage
 | Go Up        | 0 |   Logic-Half |             | 1 |   Logic-Half      
-+------------- |   | -------------+------------ |   | ---------------
 | Requests     |   |    I/O-Half  |             |   |    I/O-Half
 | Move Down    +-^-+              |             +-^-+   
 V                | Push()                         |     
   +--------------+-------------+                  |
   |   Push OnRecv Event,       |          +-------+-------+
   | 1 Event per message        |          |               | Push()
   |                            |   +------+------+ +------+------+
   |  Epoll I/O thread for      |   |Push OnTimer | |Push OnTimer |
   |multi-messaging connections |   |  Event/UI-1 | |  Event/UI-2 |
   +------^-------^--------^----+   +------+------+ +------+------+
          |       |        |               |               |                   
Incoming msg1    msg2     msg3        Msg Viewer-1    Msg Viewer-2              

:

1 , , ; , .

2 -, - Epoll, C/++ GNU Linux 2.6x; - , , , . 2 - 2 . , Win/MSVC, " " Epoll.

3 2 -, . a) Push-OnRecv ( "CMsg * pMsg = CreateMsg (msg)", C/++); b) UI , , . ( "queue.push(pMsg)" "RingBuff.push(pMsg)", C/++), , ( "pMsg- > Destroy()", C/++). MsgStage() Msg , .

4 OnTimer , Head/Tail ring buff. . Hope UI msg, , . . 3 . , OnScroll. , , OnScroll . , . . , , , OnAgedOut, .

5 , OnTimer OnRecv - , OnTimer() {} OnRecv() {} DisplayStage() MsgStage(). , , , .

6 Q0 2 , ; /. Q1 - . , , . Q2, , DisplayStage() Q1 Q2 . Q0 Q1 - , .

7 MsgStage() DisplayStage() StagedModel.Stage() , Main Thread. Epoll I/O Messaging - , MsgIO, -, Display Thread. 4 , . Effo , MsgIO .

, . EffoNetMsg.pdf http://code.google.com/p/effonetmsg/downloads/list EffoAddons.pdf http://code.google.com/p/effoaddon/downloads/list, ; . EffoDesign_LockFree.pdf http://code.google.com/p/effocore/downloads/list, , .

+3

GUI , . " ", : , , , ( ). , .

, . 5 20 ( 50-200 ).

, , ( )! , GUI RAM-, , , , / ( , , , , , ).

+1

Source: https://habr.com/ru/post/1722231/


All Articles