Boost.Thread: why would you use multiple boost threads for scheduling one user thread?How do you install Boost on MacOS?Example for boost shared_mutex (multiple reads/one write)?Modelling boost::Lockable with semaphore rather than mutex (previously titled: Unlocking a mutex from a different thread)How to run multiple threads created by loop simultaneous using boost.thread?Is it smart to replace boost::thread and boost::mutex with c++11 equivalents?Why is OpenCV function that uses TBB much faster than a Boost-based implementation?Boost w/ C++ - Curious mutex behaviorwhy “boost.thread” call “intrusive_ptr_add_ref” manually?Why boost::thread constructor doesn't accept boost::thread::attributes parameter?Why are mutexes different from atomic operations in that the former is OS level and the latter is processor level?

My players want to grind XP but we're using milestone advancement

Why would Ryanair allow me to book this journey through a third party, but not through their own website?

Should I disclose a colleague's illness (that I should not know) when others badmouth him

Are these reasonable traits for someone with autism?

What are these arcade games in Ghostbusters 1984?

Python program to find the most frequent letter in a text

Where is the logic in castrating fighters?

NIntegrate doesn't evaluate

Make 24 using exactly three 3s

How to patch glass cuts in a bicycle tire?

The art of clickbait captions

Boss wants me to falsify a report. How should I document this unethical demand?

Could a 19.25mm revolver actually exist?

How to respond to an upset student?

Externally monitoring CPU/SSD activity without software access

Is it rude to call a professor by their last name with no prefix in a non-academic setting?

Can a person survive on blood in place of water?

Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?

Why did David Cameron offer a referendum on the European Union?

Why were helmets and other body armour not commonplace in the 1800s?

Inconsistent results from Wolfram Could

using Leibniz rule to solve definite integral

How to Pin Point Large File eating space in Fedora 18

Website returning plaintext password



Boost.Thread: why would you use multiple boost threads for scheduling one user thread?


How do you install Boost on MacOS?Example for boost shared_mutex (multiple reads/one write)?Modelling boost::Lockable with semaphore rather than mutex (previously titled: Unlocking a mutex from a different thread)How to run multiple threads created by loop simultaneous using boost.thread?Is it smart to replace boost::thread and boost::mutex with c++11 equivalents?Why is OpenCV function that uses TBB much faster than a Boost-based implementation?Boost w/ C++ - Curious mutex behaviorwhy “boost.thread” call “intrusive_ptr_add_ref” manually?Why boost::thread constructor doesn't accept boost::thread::attributes parameter?Why are mutexes different from atomic operations in that the former is OS level and the latter is processor level?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm working with an existing code base that simulates a (simple) thread scheduler and creates user threads using the Boost.Thread library.



I'm confused about a design choice from the previous developer (who is unavailable to me). For each new user thread, a ThrObjWrapper object is created; that ThrObjWrapper object contains 4 Boost threads:



  • thrRun

  • thrSuspend

  • thrResume

  • thrSleep

Whenever the thread scheduler (ThrScheduler) resumes or suspends a ThrObjWrapper, the ThrObjWrapper performs operations on 2 of these threads (which 2 vary depending on whether the scheduler is resuming or suspending the threads).



I can't figure out why so many threads are necessary. Shouldn't one boost thread be sufficient? I could even understand two threads, but four? Why four?



This is the ThrScheduler's execution loop:



// curr = the current ThrObjWrapper instance being run by the ThrScheduler

if (curr != NULL)
if (curr->isThrRunning())

if (curr->isThrSuspended())
curr->thrResume();

else
curr->run();



this->sleepScheduler();

if (curr != NULL && curr->isThrRunning())
curr->thrSuspend();



This is the ThrObjWrapper class (mutexes, condition variables, getters/setters etc have been removed for brevity):



class ThrObjWrapper 
protected:
bool suspended;

boost::thread thrRun;
boost::thread thrSuspend;
boost::thread thrResume;
boost::thread thrSleep;
;

void ThrObjWrapper::thrSuspendFunc()
this->thrSuspend.interrupt();
this->thrResume.join();
this->suspended = true;

while (this->suspended)
this->thrRun.yield();



void ThrObjWrapper::thrSuspend()
this->thrSleep = boost::thread(&ThrObjWrapper::thrSuspendFunc, this);


void ThrObjWrapper::thrResumeFunc()
this->thrResume.interrupt();
this->suspended = false;
this->thrSleep.join();


void ThrObjWrapper::thrResume()
this->thrResume = boost::thread(&ThrObjWrapper::thrResumeFunc, this);


bool ThreadClass::isThrSuspended()
return this->suspended;


bool ThrObjWrapper::isThrRunning()
return thrRun.joinable();


void ThrObjWrapper::thrSleep(int time)
this->thrRun.sleep(boost::get_system_time() + boost::posix_time::milliseconds(time));


void ThrObjWrapper::run()
this->thrRun = boost::thread(&ThrObjWrapper::thrOperation, this);


void ThrObjWrapper::thrOperation()
// Performs some operation










share|improve this question






















  • At a guess he wanted all operations on the wrapper to be non blogging

    – Alan Birtles
    Mar 24 at 6:25

















0















I'm working with an existing code base that simulates a (simple) thread scheduler and creates user threads using the Boost.Thread library.



I'm confused about a design choice from the previous developer (who is unavailable to me). For each new user thread, a ThrObjWrapper object is created; that ThrObjWrapper object contains 4 Boost threads:



  • thrRun

  • thrSuspend

  • thrResume

  • thrSleep

Whenever the thread scheduler (ThrScheduler) resumes or suspends a ThrObjWrapper, the ThrObjWrapper performs operations on 2 of these threads (which 2 vary depending on whether the scheduler is resuming or suspending the threads).



I can't figure out why so many threads are necessary. Shouldn't one boost thread be sufficient? I could even understand two threads, but four? Why four?



This is the ThrScheduler's execution loop:



// curr = the current ThrObjWrapper instance being run by the ThrScheduler

if (curr != NULL)
if (curr->isThrRunning())

if (curr->isThrSuspended())
curr->thrResume();

else
curr->run();



this->sleepScheduler();

if (curr != NULL && curr->isThrRunning())
curr->thrSuspend();



This is the ThrObjWrapper class (mutexes, condition variables, getters/setters etc have been removed for brevity):



class ThrObjWrapper 
protected:
bool suspended;

boost::thread thrRun;
boost::thread thrSuspend;
boost::thread thrResume;
boost::thread thrSleep;
;

void ThrObjWrapper::thrSuspendFunc()
this->thrSuspend.interrupt();
this->thrResume.join();
this->suspended = true;

while (this->suspended)
this->thrRun.yield();



void ThrObjWrapper::thrSuspend()
this->thrSleep = boost::thread(&ThrObjWrapper::thrSuspendFunc, this);


void ThrObjWrapper::thrResumeFunc()
this->thrResume.interrupt();
this->suspended = false;
this->thrSleep.join();


void ThrObjWrapper::thrResume()
this->thrResume = boost::thread(&ThrObjWrapper::thrResumeFunc, this);


bool ThreadClass::isThrSuspended()
return this->suspended;


bool ThrObjWrapper::isThrRunning()
return thrRun.joinable();


void ThrObjWrapper::thrSleep(int time)
this->thrRun.sleep(boost::get_system_time() + boost::posix_time::milliseconds(time));


void ThrObjWrapper::run()
this->thrRun = boost::thread(&ThrObjWrapper::thrOperation, this);


void ThrObjWrapper::thrOperation()
// Performs some operation










share|improve this question






















  • At a guess he wanted all operations on the wrapper to be non blogging

    – Alan Birtles
    Mar 24 at 6:25













0












0








0








I'm working with an existing code base that simulates a (simple) thread scheduler and creates user threads using the Boost.Thread library.



I'm confused about a design choice from the previous developer (who is unavailable to me). For each new user thread, a ThrObjWrapper object is created; that ThrObjWrapper object contains 4 Boost threads:



  • thrRun

  • thrSuspend

  • thrResume

  • thrSleep

Whenever the thread scheduler (ThrScheduler) resumes or suspends a ThrObjWrapper, the ThrObjWrapper performs operations on 2 of these threads (which 2 vary depending on whether the scheduler is resuming or suspending the threads).



I can't figure out why so many threads are necessary. Shouldn't one boost thread be sufficient? I could even understand two threads, but four? Why four?



This is the ThrScheduler's execution loop:



// curr = the current ThrObjWrapper instance being run by the ThrScheduler

if (curr != NULL)
if (curr->isThrRunning())

if (curr->isThrSuspended())
curr->thrResume();

else
curr->run();



this->sleepScheduler();

if (curr != NULL && curr->isThrRunning())
curr->thrSuspend();



This is the ThrObjWrapper class (mutexes, condition variables, getters/setters etc have been removed for brevity):



class ThrObjWrapper 
protected:
bool suspended;

boost::thread thrRun;
boost::thread thrSuspend;
boost::thread thrResume;
boost::thread thrSleep;
;

void ThrObjWrapper::thrSuspendFunc()
this->thrSuspend.interrupt();
this->thrResume.join();
this->suspended = true;

while (this->suspended)
this->thrRun.yield();



void ThrObjWrapper::thrSuspend()
this->thrSleep = boost::thread(&ThrObjWrapper::thrSuspendFunc, this);


void ThrObjWrapper::thrResumeFunc()
this->thrResume.interrupt();
this->suspended = false;
this->thrSleep.join();


void ThrObjWrapper::thrResume()
this->thrResume = boost::thread(&ThrObjWrapper::thrResumeFunc, this);


bool ThreadClass::isThrSuspended()
return this->suspended;


bool ThrObjWrapper::isThrRunning()
return thrRun.joinable();


void ThrObjWrapper::thrSleep(int time)
this->thrRun.sleep(boost::get_system_time() + boost::posix_time::milliseconds(time));


void ThrObjWrapper::run()
this->thrRun = boost::thread(&ThrObjWrapper::thrOperation, this);


void ThrObjWrapper::thrOperation()
// Performs some operation










share|improve this question














I'm working with an existing code base that simulates a (simple) thread scheduler and creates user threads using the Boost.Thread library.



I'm confused about a design choice from the previous developer (who is unavailable to me). For each new user thread, a ThrObjWrapper object is created; that ThrObjWrapper object contains 4 Boost threads:



  • thrRun

  • thrSuspend

  • thrResume

  • thrSleep

Whenever the thread scheduler (ThrScheduler) resumes or suspends a ThrObjWrapper, the ThrObjWrapper performs operations on 2 of these threads (which 2 vary depending on whether the scheduler is resuming or suspending the threads).



I can't figure out why so many threads are necessary. Shouldn't one boost thread be sufficient? I could even understand two threads, but four? Why four?



This is the ThrScheduler's execution loop:



// curr = the current ThrObjWrapper instance being run by the ThrScheduler

if (curr != NULL)
if (curr->isThrRunning())

if (curr->isThrSuspended())
curr->thrResume();

else
curr->run();



this->sleepScheduler();

if (curr != NULL && curr->isThrRunning())
curr->thrSuspend();



This is the ThrObjWrapper class (mutexes, condition variables, getters/setters etc have been removed for brevity):



class ThrObjWrapper 
protected:
bool suspended;

boost::thread thrRun;
boost::thread thrSuspend;
boost::thread thrResume;
boost::thread thrSleep;
;

void ThrObjWrapper::thrSuspendFunc()
this->thrSuspend.interrupt();
this->thrResume.join();
this->suspended = true;

while (this->suspended)
this->thrRun.yield();



void ThrObjWrapper::thrSuspend()
this->thrSleep = boost::thread(&ThrObjWrapper::thrSuspendFunc, this);


void ThrObjWrapper::thrResumeFunc()
this->thrResume.interrupt();
this->suspended = false;
this->thrSleep.join();


void ThrObjWrapper::thrResume()
this->thrResume = boost::thread(&ThrObjWrapper::thrResumeFunc, this);


bool ThreadClass::isThrSuspended()
return this->suspended;


bool ThrObjWrapper::isThrRunning()
return thrRun.joinable();


void ThrObjWrapper::thrSleep(int time)
this->thrRun.sleep(boost::get_system_time() + boost::posix_time::milliseconds(time));


void ThrObjWrapper::run()
this->thrRun = boost::thread(&ThrObjWrapper::thrOperation, this);


void ThrObjWrapper::thrOperation()
// Performs some operation







c++ boost boost-thread






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 4:03









dreaded_moldreaded_mol

162




162












  • At a guess he wanted all operations on the wrapper to be non blogging

    – Alan Birtles
    Mar 24 at 6:25

















  • At a guess he wanted all operations on the wrapper to be non blogging

    – Alan Birtles
    Mar 24 at 6:25
















At a guess he wanted all operations on the wrapper to be non blogging

– Alan Birtles
Mar 24 at 6:25





At a guess he wanted all operations on the wrapper to be non blogging

– Alan Birtles
Mar 24 at 6:25












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320626%2fboost-thread-why-would-you-use-multiple-boost-threads-for-scheduling-one-user-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320626%2fboost-thread-why-would-you-use-multiple-boost-threads-for-scheduling-one-user-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현