can i insert msg in the head ( wxMessageQueue ) Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
宝挖小子
In need of some credit
In need of some credit
Posts: 8
Joined: Fri Dec 23, 2016 6:05 am

can i insert msg in the head ( wxMessageQueue )

Post by 宝挖小子 »

can i insert msg in the head ( wxMessageQueue )
eg:
wxMessageQueue <int> msg;
msg={1,2,3,4,5}

now i want insert data 10 make msg={10,1,2,3,4,5};

can wxMessageQueue do this?

i just want the next msg.front=10;

or has some other class like as wxMessageQueue ,thread safe?
I am genius and man will conquer the nature
MagickPanda
Experienced Solver
Experienced Solver
Posts: 81
Joined: Wed Oct 19, 2016 1:41 pm

Re: can i insert msg in the head ( wxMessageQueue )

Post by MagickPanda »

According to the docs you can only append new message to the back of the wxMessageQueue class.
For thread-safe data, why not just use wxMutexLocker to lock shared data between different thread, which is more flexible than using wxMessageQueue(which is not designed to store custom user info and sort manipulation).
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: can i insert msg in the head ( wxMessageQueue )

Post by doublemax »

wxMessageQueue is a very small, header-only class defined in <wxdir>/include/msgqueue.h

You can copy that file to your own project, rename the class and then modify it.
Use the source, Luke!
User avatar
宝挖小子
In need of some credit
In need of some credit
Posts: 8
Joined: Fri Dec 23, 2016 6:05 am

Re: can i insert msg in the head ( wxMessageQueue )

Post by 宝挖小子 »

doublemax wrote:wxMessageQueue is a very small, header-only class defined in <wxdir>/include/msgqueue.h

You can copy that file to your own project, rename the class and then modify it.
yeah,that seems a good idea
I am genius and man will conquer the nature