Removed asyncHandler and creating new threads now once buffer-vector is complete
parent
f1e8069afd
commit
a0ae919614
@ -1,17 +0,0 @@
|
|||||||
#ifndef EFFCCB40_3639_4BD4_9649_302F05987909
|
|
||||||
#define EFFCCB40_3639_4BD4_9649_302F05987909
|
|
||||||
|
|
||||||
#include <future>
|
|
||||||
#include <string.h>
|
|
||||||
#include "bufHandler.hpp"
|
|
||||||
|
|
||||||
void asyncHandler(char *buf){
|
|
||||||
// Create a copy of buf for our thread
|
|
||||||
char bufCopy[265];
|
|
||||||
strcpy(bufCopy, buf);
|
|
||||||
|
|
||||||
// \/ Surpress unused warning
|
|
||||||
(void)std::async(std::launch::async, bufHandler, bufCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* EFFCCB40_3639_4BD4_9649_302F05987909 */
|
|
@ -1,22 +1,24 @@
|
|||||||
#ifndef C251BA62_6D80_4033_86B6_61F184E6F250
|
#ifndef C251BA62_6D80_4033_86B6_61F184E6F250
|
||||||
#define C251BA62_6D80_4033_86B6_61F184E6F250
|
#define C251BA62_6D80_4033_86B6_61F184E6F250
|
||||||
|
|
||||||
|
#include <future>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "textPacketHandler.hpp"
|
#include "textPacketHandler.hpp"
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
||||||
std::vector<std::string> buffer;
|
std::vector<std::string> buffer;
|
||||||
void bufHandler(char *buf){
|
void bufHandler(const char *buf){
|
||||||
// When first char of buf has text (no tab), we got a new packet
|
// When first char of buf has text (no tab), we got a new packet
|
||||||
if(buf[0] != '\t'){
|
if(buf[0] != '\t'){
|
||||||
// Submit the just-read text-packet
|
// Submit the just-read text-packet in a new thread
|
||||||
if(buffer.size() != 0) textPacketHandler(buffer);
|
if(buffer.size() != 0) {
|
||||||
buffer = std::vector<std::string>();
|
(void)std::async(std::launch::async, textPacketHandler, buffer);
|
||||||
}
|
}
|
||||||
|
buffer = {std::string(buf)};
|
||||||
// Append part-packet
|
}
|
||||||
buffer.push_back(buf);
|
else
|
||||||
|
buffer.push_back(std::string(buf)); // Append part-packet
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* C251BA62_6D80_4033_86B6_61F184E6F250 */
|
#endif /* C251BA62_6D80_4033_86B6_61F184E6F250 */
|
||||||
|
Loading…
Reference in New Issue