imgregduh's Profile User Rating: -----

Reputation: 0 Apprentice
Active Members
Active Posts:
57 (0.04 per day)
15-May 11
Profile Views:
Last Active:
User is offline Feb 04 2013 02:19 PM

Previous Fields

Dream Kudos:
Icon   imgregduh has not set their status

Posts I've Made

  1. In Topic: "@help" function; maybe threading ?

    Posted 3 Feb 2013

    View PostSkydiver, on 03 February 2013 - 05:06 PM, said:

    If you are changing the code substantially, you should have posted a reply and not changed your original post because it breaks the continuity of the thread for any late comers to this thread.

    Anyway you are trying to get input both on line 11 and line 26. I don't think that the standard C++ input is thread-safe, nor will it work the way you are expecting it to. It seems that you are assuming that the C++ library will coalesce the two input calls, and that somehow it will magically determine which one of the input readers will run and choke off the other one.

    undefined behaviour's recommendation is still the most appropriate. Only do input and parsing from one thread. If you really want to go multi-threaded execution of actions, start the action after the input and parsing.

    alright throwing the threading idea out of the picture,
    let me try to draw a picture to describe what i am talking about

    ask user question expecting string input->
    enter input in console ->
    checks the string for certain word ->
    if string passes ignore previous function ->
    enter into function that originally asked the question

    lets say the function that is asking the question only wants a single string to be taken in

    im trying to avoid placing a conditional statement around all the input locations in my entire program just to look for one word


    found a possible solution
    class MyCin
        MyCin& operator>> (std::string rhs)
                std::cin >> rhs;
                if (rhs == "/help")
                    std::cout << "Help message";
            return *this;

    overload the operator>> for it to check for "/help" then continue after the check
  2. In Topic: "@help" function; maybe threading ?

    Posted 3 Feb 2013

    View Postundefined behaviour, on 03 February 2013 - 07:30 AM, said:

    This testcase is incomplete; We can't reproduce the problem you're experiencing.

    Perhaps it might be a better idea to design your console application as a single-threaded one, and then use your profiler to determine where to expose parallelism. Not only will you have less debugging to do, but you will also be able to make useful statements regarding the optimisation you've done, rather than guessing and not quite targetting it correctly.

    i simplified the example for it to ask a simple question and wait for an input.

    in the example, i ran it and i have to input for the help function and for the input in the main function im trying avoid entering the information twice and only have one input go through each function once

    at the moment with the given code avoid if i enter "something" as input i have to do it twice for it to be entered. the first somone is being inputted into the help function then the second one is being taken in for the main function

My Information

Member Title:
D.I.C Head
Age Unknown
Birthday Unknown

Contact Information



imgregduh hasn't added any friends yet.


imgregduh has no profile comments yet. Why not say hello?