x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Closed] How to fix "LogStats:Warning: MetaData mismatch. Did you assign a stat to two groups?"

Hello,

I need to create two threads. I base my code on this Rama tutorial:

https://wiki.unrealengine.com/Multi-Threading:_How_to_Create_Threads_in_UE4

Whan I do it, I get a message in the log:

LogStats:Warning: MetaData mismatch. Did you assign a stat to two groups? New //STATGROUP_Threads//FTCPSocketListeningTh///Thread_2130_0///####STATCAT_Advanced#### old //STATGROUP_Threads//FTCPSocketListeningTh///Thread_202c_0///####STATCAT_Advanced####

And my second thread dont stop opposed to in the first. I read, it because of the same name, but I called the threads different.

Help me fix it. Thanks!

.

.

.

Code of my two identical FRunnable class -- FServerStatusCheckingTh and FTCPSocketListeningTh.

.h

 #pragma once
 
 class SIENNACLIENTPROJECT_API FServerStatusCheckingTh : public FRunnable
 {
     static  FServerStatusCheckingTh* Runnable;
 
     FRunnableThread* Thread;
 
 public:
 
     FServerStatusCheckingTh();
     ~FServerStatusCheckingTh();
 
     virtual bool   Init();
     virtual uint32 Run();
     virtual void   Stop();
 
     static FServerStatusCheckingTh* RunServerChecking();
 
     static bool bThreadRun;
 
     static void Shutdown();
 
 };
 

.cpp

 #include "SiennaClientProject.h"
 #include "ServerStatusCheckingTh.h"
 
 FServerStatusCheckingTh* FServerStatusCheckingTh::Runnable = NULL;
 bool FServerStatusCheckingTh::bThreadRun = false;
 
 FServerStatusCheckingTh::FServerStatusCheckingTh()
 {
     Thread = FRunnableThread::Create(this, TEXT("ServerStatusChecking"), 0, TPri_BelowNormal); 
 }
 
 FServerStatusCheckingTh::~FServerStatusCheckingTh()
 {
     delete Thread;
     Thread = NULL;
 }
 
 bool FServerStatusCheckingTh::Init()
 {
     bThreadRun = true;
     return true;
 }
 
 uint32 FServerStatusCheckingTh::Run()
 {
     while (bThreadRun)
     {
         FPlatformProcess::Sleep(1.f); 
     GLog->Log("FServerStatusCheckingTh");
         
     }
     return 0;
 }
 
 void FServerStatusCheckingTh::Stop()
 {
 }
 
 FServerStatusCheckingTh* FServerStatusCheckingTh::RunServerChecking()
 {
     if (!Runnable && FPlatformProcess::SupportsMultithreading())
     {
         Runnable = new FServerStatusCheckingTh();
     }
     return Runnable;
 }
 
 void FServerStatusCheckingTh::Shutdown()
 {
     if (Runnable)
     {
         bThreadRun = false;
 
         delete Runnable;
         Runnable = NULL;
     }
 }
 
 

In FTCPSocketListeningTh change only the displayed message in the log and thread name

.h

 #pragma once
 
 class SIENNACLIENTPROJECT_API FTCPSocketListeningTh : public FRunnable
 {
     static FTCPSocketListeningTh* Runnable;
 
     FRunnableThread* Thread;
 
 public:
 
     FTCPSocketListeningTh();
     ~FTCPSocketListeningTh();
 
     virtual bool   Init();
     virtual uint32 Run();
     virtual void   Stop();
 
     static FTCPSocketListeningTh* RunSocketListening();
 
     static bool bThreadRun;
 
     static void Shutdown();
 
 };

.cpp

 #include "SiennaClientProject.h"
 #include "TCPSocketListeningTh.h"
 
 FTCPSocketListeningTh* FTCPSocketListeningTh::Runnable = NULL;
 bool FTCPSocketListeningTh::bThreadRun = false;
 
 FTCPSocketListeningTh::FTCPSocketListeningTh()
 {
     Thread = FRunnableThread::Create(this, TEXT("TCP_SocketListening"), 0, TPri_BelowNormal); 
 }
 
 FTCPSocketListeningTh::~FTCPSocketListeningTh()
 {
     delete Thread;
     Thread = NULL;
 }
 
 bool FTCPSocketListeningTh::Init()
 {
     bThreadRun = true;
     return true;
 }
 
 uint32 FTCPSocketListeningTh::Run()
 {
     while (bThreadRun)
     {
         FPlatformProcess::Sleep(1.f);
         GLog->Log("FTCPSocketListeningTh");
     }
     return 0;
 }
 
 void FTCPSocketListeningTh::Stop()
 {
 }
 
 FTCPSocketListeningTh* FTCPSocketListeningTh::RunSocketListening()
 {
     if (!Runnable && FPlatformProcess::SupportsMultithreading())
     {
         Runnable = new FTCPSocketListeningTh();
     }
     return Runnable;
 }
 
 void FTCPSocketListeningTh::Shutdown()
 {
     if (Runnable)
     {
         bThreadRun = false;
 
         delete Runnable;
         Runnable = NULL;
     }
 }
 
 

Run and Shutdown in GameInstance:

 void USiennaGameInstance::Init()
 {
     GLog->Log("<<< USiennaGameInstance::USiennaGameInstance >>>");
 
         FServerStatusCheckingTh::RunServerChecking(); 
     FTCPSocketListeningTh::RunSocketListening();
 }
 
 void USiennaGameInstance::Shutdown()
 {
     FTCPSocketListeningTh::Shutdown();
     FServerStatusCheckingTh::Shutdown();
 }
 







Product Version: UE 4.13
Tags:
more ▼

asked Sep 15 '16 at 01:47 PM in C++ Programming

avatar image

Syntopia
222 22 28 45

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The question has been closed Sep 16 '16 at 10:09 AM by Syntopia for the following reason:

The question is answered, right answer was accepted


1 answer: sort voted first

Solved, I called a function to create a threads multiple times) eventually create a threads with the same name.

Morality of story: in any strange situation, go to sleep)

more ▼

answered Sep 16 '16 at 10:08 AM

avatar image

Syntopia
222 22 28 45

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question