Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rattrap

Member Since 03 Nov 2004
Online Last Active Today, 08:28 PM

Posts I've Made

In Topic: Can't Reply On Chrome

18 July 2016 - 10:07 PM

Win10 Pro and Chrome as well.  I see what you do, but after I click in the reply box, the editing tools show up like you see in Opera.


In Topic: Work queue with condition variable - design issue

14 June 2016 - 08:22 AM

As far as the priority side, can you wrap the job in another structure that holds the priority as well, then just use a priority_queue ?


In Topic: Work queue with condition variable - design issue

14 June 2016 - 08:15 AM

I've done something similar recently (not the priority side).

 

I actually made an atomic enum that tracked the state of the worker thread.

enum class WorkerThreadState : int
{
	CheckingForJob,
	RunningJob,
	Sleeping,
	Terminating,
	ReadyToJoin,
	Joined
};

std::atomic<WorkerThreadState> State{WorkerThreadState::CheckingForJob};

I could then use the atomic compare_exchange commands to test the state to see if it was safe to change or if it had changed to a terminating state, leave it alone.

And since I had a reference to the state outside of the thread, I could query what the thread was doing at the moment.

 

[edit]

Thread would start as CheckingForJob.  It would atomically check if the State was still CheckingForJob before checking the queue.  If it wasn't, then it was likely triggered to shutdown (Terminating).  This could have happened while processing a previous job.  Once a job was retrieved, it was set to RunningJob.  If no jobs were available, it would be set to Sleeping and wait for a condition variable to be triggered to check again.  The controlling thread would set the variable to Terminating when it was ready for it to shut down.  When set to Terminating, once whatever job it was working on was complete, it would stop the loop and set itself as ReadyToJoin.  A function outside the WorkerThread would check the vector of worker threads for threads that were ReadyToJoin and call join on them, then remove them from the vector.


In Topic: When things don't look the way things are

13 June 2016 - 07:21 AM

I can't stand warnings either.  Currently the ones that have driven me the most mad are Intellisense warnings in VS 2015.  The code is right and works, but I think the templated nature of the code is a little too much for Intellisense. It reports that a function doesn't exist, despite compiling and executing just fine.

 

I remember doing something similar. I started writing a forum post so some other eyes could look at some code I couldn't get to compile and looked right to me.  As I was writing the post, I was actually writing out a list of expected responses, which then led me to realize what was actually wrong with the code.


In Topic: Creating Cross-Platform Code

30 May 2016 - 06:40 AM

Thought I'd add that the upcoming Windows 10 Anniversary update will be adding some "native" Linux support. While you might not be able to test the program itself (not sure how much will or won't work), you will be able to run GCC from bash directly from Windows.

PARTNERS