Click here to Skip to main content
13,624,821 members

C / C++ / MFC

 
PinnedHOW TO ANSWER A QUESTION Pin
Chris Maunder12-Jul-09 22:37
adminChris Maunder12-Jul-09 22:37 
PinnedHOW TO ASK A QUESTION Pin
Chris Maunder12-Feb-09 17:19
adminChris Maunder12-Feb-09 17:19 
QuestionCChildFrame in separate thread Pin
_Flaviu1 hr 9mins ago
member_Flaviu1 hr 9mins ago 
AnswerRe: CChildFrame in separate thread Pin
Jochen Arndt38mins ago
mvpJochen Arndt38mins ago 
GeneralRe: CChildFrame in separate thread Pin
_Flaviu23mins ago
member_Flaviu23mins ago 
QuestionTrace a CString Pin
_Flaviu14-Jul-18 22:26
member_Flaviu14-Jul-18 22:26 
AnswerRe: Trace a CString Pin
Richard MacCutchan21hrs 15mins ago
protectorRichard MacCutchan21hrs 15mins ago 
SuggestionRe: Trace a CString Pin
David Crow6hrs 48mins ago
memberDavid Crow6hrs 48mins ago 
GeneralRe: Trace a CString Pin
_Flaviu1 hr 11mins ago
member_Flaviu1 hr 11mins ago 
AnswerRe: Trace a CString Pin
Jochen Arndt3mins ago
mvpJochen Arndt3mins ago 
Questionmapping pthread id to custom id Pin
meerokh13-Jul-18 5:51
membermeerokh13-Jul-18 5:51 
After creating a pthread, i am setting the thread id to a custom id using a map.

pthread_t threads[noOfThreads];
struct thread_data td[noOfThreads];// a struct which only contains int thread_id
thread= pthread_create(&threads[i], NULL, startFunc, (void *)&td[i]);
setID(threads[i], td[i].thread_id);


SetID function
setID(pthread_t pid, int id ){
	thread_ids[pid]=id;// How can i access this value in getID function?? 


definition of map
std::map<pthread_t, int> thread_ids;


I want to get the mapped value based on the key value in the following function but dont know how to do exactly.

getID function
getID() {

	if (thread_ids.find(pid) ==thread_ids.end()) return -1;
	return thread_ids[pid];//
}


I am very beginner so spare me if i am making a stupid mistake and please point that and help me correcting it
c++, pthread


modified 2 days ago.

GeneralRe: mapping pthread id to custom id Pin
Richard MacCutchan13-Jul-18 20:48
protectorRichard MacCutchan13-Jul-18 20:48 
GeneralRe: mapping pthread id to custom id Pin
meerokh14-Jul-18 0:24
membermeerokh14-Jul-18 0:24 
GeneralRe: mapping pthread id to custom id Pin
Richard MacCutchan14-Jul-18 3:36
protectorRichard MacCutchan14-Jul-18 3:36 
QuestionHow to disable a HTML Input in c# Pin
Member 1219465611-Jul-18 15:50
memberMember 1219465611-Jul-18 15:50 
AnswerRe: How to disable a HTML Input in c# Pin
Bryian Tan11-Jul-18 17:30
mvpBryian Tan11-Jul-18 17:30 
Questionc++ - std :: map - Is my idea too dirty? Pin
0x01AA11-Jul-18 8:40
professional0x01AA11-Jul-18 8:40 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
harold aptroot11-Jul-18 9:48
memberharold aptroot11-Jul-18 9:48 
PraiseRe: c++ - std :: map - Is my idea too dirty? Pin
0x01AA11-Jul-18 9:54
professional0x01AA11-Jul-18 9:54 
AnswerRe: c++ - std :: map - Is my idea too dirty? Pin
Richard MacCutchan11-Jul-18 19:44
protectorRichard MacCutchan11-Jul-18 19:44 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
harold aptroot12-Jul-18 12:34
memberharold aptroot12-Jul-18 12:34 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
Richard MacCutchan12-Jul-18 19:42
protectorRichard MacCutchan12-Jul-18 19:42 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
harold aptroot12-Jul-18 20:19
memberharold aptroot12-Jul-18 20:19 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
Richard MacCutchan12-Jul-18 20:41
protectorRichard MacCutchan12-Jul-18 20:41 
GeneralRe: c++ - std :: map - Is my idea too dirty? Pin
0x01AA13-Jul-18 7:44
professional0x01AA13-Jul-18 7:44 

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.


Advertise | Privacy | Cookies | Terms of Service
Web02-2016 | 2.8.180712.1 | Last Updated 16 Jul 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid