Author Topic: how can i allocate memory when using ThreadPool library  (Read 7367 times)

jacey_48557

  • Not-a-newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
how can i allocate memory when using ThreadPool library
« on: October 24, 2012, 08:23:03 PM »
can someone help me?  thanks in advance !

I am using ThreadPool library to create multy threads. the operate system use the default thread space,

so that , i can only create limited thread .

Now, that i want to create more threads , what should i do?


wish someone who know it would help me and explain it to me,  thanks very much!

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: how can i allocate memory when using ThreadPool library
« Reply #1 on: October 25, 2012, 12:50:40 PM »
ThreadPool is a single file and not complex. So look for RakNet::RakThread::Create in that file and change it as you need to.

jacey_48557

  • Not-a-newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: how can i allocate memory when using ThreadPool library
« Reply #2 on: November 08, 2012, 02:33:55 AM »
 thanks for answer.

 But, i really can not understand how could i create more threads in a threadpool, so that please,

can you give me clear way that i could solve it , thanks very much!

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: how can i allocate memory when using ThreadPool library
« Reply #3 on: November 08, 2012, 10:26:33 AM »
I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

jacey_48557

  • Not-a-newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: how can i allocate memory when using ThreadPool library
« Reply #4 on: November 08, 2012, 10:59:36 PM »
I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

thanks.

for default thread space, i means that the default thread stack size use in raknet,

and , i know that in raknet, the default thread stack size is defined as a macro definition , but i can't change the the default size of ThreadPool when created.

so, thank you very much .

jacey_48557

  • Not-a-newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: how can i allocate memory when using ThreadPool library
« Reply #5 on: November 09, 2012, 01:36:06 AM »
I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

i am so sorry to trouble you that could you answer a question of me?

that, i am doing with the autoPatcher, and the problem is about the function SetupReceive();



details:

the client send a request that patch a application, and then ,the server returns, 

the function "AutopatcherClient::OnCreationList(Packet *packet)" is called.

when function Prepare the transfer plugin to get a file list, it called the function SetupReceive();  And SetupReceive() returns -1 because of

the client have already connected to the server(i don't know why did it like that).


my question is:
   
    How could i do with that?   If the client connected to the server wrong? or that , should i call SetupReceive() before the connect? Thank you

for answer me, and sorry for my bad english.
   



Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: how can i allocate memory when using ThreadPool library
« Reply #6 on: November 09, 2012, 09:54:12 AM »
I already said the default size of threadpool is the 2nd parameter of StartThreads.

I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

thanks.

for default thread space, i means that the default thread stack size use in raknet,

and , i know that in raknet, the default thread stack size is defined as a macro definition , but i can't change the the default size of ThreadPool when created.

so, thank you very much .

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: how can i allocate memory when using ThreadPool library
« Reply #7 on: November 09, 2012, 10:06:52 AM »
I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

i am so sorry to trouble you that could you answer a question of me?

that, i am doing with the autoPatcher, and the problem is about the function SetupReceive();



details:

the client send a request that patch a application, and then ,the server returns, 

the function "AutopatcherClient::OnCreationList(Packet *packet)" is called.

when function Prepare the transfer plugin to get a file list, it called the function SetupReceive();  And SetupReceive() returns -1 because of

the client have already connected to the server(i don't know why did it like that).


my question is:
   
    How could i do with that?   If the client connected to the server wrong? or that , should i call SetupReceive() before the connect? Thank you

for answer me, and sorry for my bad english.
   




In FileListTransfer::SetupReceive() what does it return from rakPeerInterface->GetConnectionState(allowedSender)? Did you keep the connection to the server active while patching?

jacey_48557

  • Not-a-newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: how can i allocate memory when using ThreadPool library
« Reply #8 on: November 11, 2012, 10:10:14 PM »
I don't know what you mean by default thread space. If you mean the stack size per thread, this is the 2nd parameter of StartThreads. Otherwise I don't know how you would create more threads than some other limit.

i am so sorry to trouble you that could you answer a question of me?

that, i am doing with the autoPatcher, and the problem is about the function SetupReceive();



details:

the client send a request that patch a application, and then ,the server returns, 

the function "AutopatcherClient::OnCreationList(Packet *packet)" is called.

when function Prepare the transfer plugin to get a file list, it called the function SetupReceive();  And SetupReceive() returns -1 because of

the client have already connected to the server(i don't know why did it like that).


my question is:
   
    How could i do with that?   If the client connected to the server wrong? or that , should i call SetupReceive() before the connect? Thank you

for answer me, and sorry for my bad english.
   




In FileListTransfer::SetupReceive() what does it return from rakPeerInterface->GetConnectionState(allowedSender)? Did you keep the connection to the server active while patching?


sorry for my late reply.

surely , rakPeerInterface->GetConnectionState(allowedSender) returns IS_CONNECTED,  means that

 raknet require that FileListTransfer::SetupReceive() should be called before the connection between client and server? But how can i(client) communicate

with the server and send a download request to the server without a connection?

in fact , i am using the udp protocal.