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"

How is the flag 'bAutoDeleteRunnable' and 'bAutoDeleteSelf' in FRunnableThread::Create(...) used?

Hey there,

I am currently struggling with a FRunnable I created.. I set up a custom FMessageHandler inheriting FRunnable to read messages coming in via tcp. This works quite well, but I want this thing to clear its local 'Instance' field when the client disconnects (which I currently determine via ping'ing it from Server->Client).

This is my create call: Thread = FRunnableThread::Create(this, TEXT("FMessageListener"), true, true, 0, TPri_BelowNormal);

To get the messages inside my managing class, I bound a local method which gets called when a message arrived. If the message is "DISCONNECT" I set the IsActive flag to false which in turn should the Run-method inside the Thread cause to quit. After that I thought the Thread somehow knows its "done" now and will auto-delete itself. But it wont...

Any information on this? When is this auto-deletion happening? Do I get this wrong? If thats not the way to use this, then how can I delete my Instance, so that another connecting client can get its "own" instance for communication?

Thanks in advance..

Tim

EDIT: I just saw, that: "'FRunnableThread::Create': Function deprecated. Use FRunnableThread::Create without bAutoDeleteSelf and bAutoDeleteRunnable params and delete thread and runnable manually. "

Product Version: UE 4.17
Tags:
more ▼

asked Aug 21 '17 at 10:53 AM in C++ Programming

avatar image

TimEdelmann
1 1

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

1 answer: sort voted first

It looks like I found a possible answer for this myself! After finding out, that bAutoDeleteSelf and bAutoDeleteRunnable are deprecated. I switched to a "lazy", but manually deletion of Thread and Runnable-Instance. Now these are deleted when a new client wants to connect and NOT at the end of processing a client!

 UE_LOG(AliceRT, Warning, TEXT("Client wants to connect. "));
 if (!FMessageHandler::Instance) // no instance yet? create one
 {
             ...
     FMessageHandler::CreateInstance(Socket);
             ...
     return true;
 }
     // instance available but inaktive? delete old one and create new
 else if (FMessageHandler::Instance && !FMessageHandler::Instance->IsActive)
 {
     delete FMessageHandler::Instance->Thread;
     FMessageHandler::Instance->Thread = nullptr;
     delete FMessageHandler::Instance;
     FMessageHandler::Instance = nullptr;

             ...
     FMessageHandler::CreateInstance(Socket);
             ...
     return true;
 }

This works fine now!

more ▼

answered Aug 21 '17 at 12:27 PM

avatar image

TimEdelmann
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

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

Answers to this question