Click here to Skip to main content
16,015,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalbasic_string Pin
Niklas L4-Apr-02 21:37
Niklas L4-Apr-02 21:37 
GeneralRe: basic_string Pin
Niklas L4-Apr-02 21:39
Niklas L4-Apr-02 21:39 
GeneralRe: basic_string Pin
Joaquín M López Muñoz4-Apr-02 22:32
Joaquín M López Muñoz4-Apr-02 22:32 
GeneralRe: basic_string Pin
Joao Vaz4-Apr-02 23:49
Joao Vaz4-Apr-02 23:49 
GeneralRe: basic_string Pin
Tim Smith5-Apr-02 3:48
Tim Smith5-Apr-02 3:48 
GeneralRe: basic_string Pin
Joao Vaz5-Apr-02 4:56
Joao Vaz5-Apr-02 4:56 
GeneralRe: basic_string Pin
Joaquín M López Muñoz5-Apr-02 5:40
Joaquín M López Muñoz5-Apr-02 5:40 
GeneralRe: basic_string Pin
Joao Vaz5-Apr-02 6:03
Joao Vaz5-Apr-02 6:03 
Joaquín M López Muñoz wrote:
Consider for example a for_each operation performed on a std::vector: as for_each only sees the vector thru iterators, this implies that the operation locks and unlocks the vector every time it accesses it. In many occasions one will need that the entire for_each operation is done within a single lock section

Of course with full mt semantics this will lock every operation, but imagine two threads writing to the same vector, and the vector doesn't care about the order in wich threads write, this will improve concurrency , than serializing all the insertions ...
If you want the transversal of vector to be more quickly, you would define the normal thread safe model that most STL implementations use, so using for_each will increase the speed of the loop.
So when you define your vector you must think carefully if this vector will be used much more times in a read scenario than a write scenario or vice-versa.

You could use also template operator= to convert on the fly the vector with threadmodel MT to be used with the normal Thread Read Safe model(possibly very costly or not advisable at all), or you could use the Adaptor Pattern to adapt the class to a different thread model ...

Cheers,


Joao Vaz
GeneralRe: basic_string Pin
Niklas L5-Apr-02 1:12
Niklas L5-Apr-02 1:12 
GeneralPLEASE HELP ME Pin
cycosi4-Apr-02 21:12
cycosi4-Apr-02 21:12 
GeneralRe: PLEASE HELP ME Pin
Mazdak4-Apr-02 21:27
Mazdak4-Apr-02 21:27 
GeneralRe: PLEASE HELP ME Pin
Christian Graus4-Apr-02 21:37
protectorChristian Graus4-Apr-02 21:37 
GeneralRe: PLEASE HELP ME Pin
cycosi4-Apr-02 22:41
cycosi4-Apr-02 22:41 
GeneralRe: PLEASE HELP ME Pin
Christian Graus4-Apr-02 22:58
protectorChristian Graus4-Apr-02 22:58 
GeneralRe: PLEASE HELP ME Pin
Tomasz Sowinski5-Apr-02 6:02
Tomasz Sowinski5-Apr-02 6:02 
GeneralVery Basic Question. Pin
Mazdak4-Apr-02 20:14
Mazdak4-Apr-02 20:14 
GeneralRe: Very Basic Question. Pin
Joaquín M López Muñoz4-Apr-02 20:28
Joaquín M López Muñoz4-Apr-02 20:28 
GeneralRe: Very Basic Question. Pin
Mazdak4-Apr-02 20:34
Mazdak4-Apr-02 20:34 
GeneralRe: Very Basic Question. Pin
Joaquín M López Muñoz4-Apr-02 20:44
Joaquín M López Muñoz4-Apr-02 20:44 
GeneralRe: Very Basic Question. Pin
Mazdak4-Apr-02 20:54
Mazdak4-Apr-02 20:54 
GeneralRe: Very Basic Question. Pin
Joaquín M López Muñoz4-Apr-02 21:08
Joaquín M López Muñoz4-Apr-02 21:08 
GeneralRe: Very Basic Question. Pin
Mazdak4-Apr-02 21:24
Mazdak4-Apr-02 21:24 
GeneralRe: Very Basic Question. Pin
Niklas L4-Apr-02 21:08
Niklas L4-Apr-02 21:08 
GeneralRe: Very Basic Question. Pin
Mazdak4-Apr-02 21:22
Mazdak4-Apr-02 21:22 
GeneralRe: Very Basic Question. Pin
PJ Arends4-Apr-02 21:11
professionalPJ Arends4-Apr-02 21:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.