From owner-freebsd-threads@FreeBSD.ORG Sun Nov 6 04:07:51 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E13E816A420 for ; Sun, 6 Nov 2005 04:07:51 +0000 (GMT) (envelope-from oceanare@pacific.net.sg) Received: from smtpgate1.pacific.net.sg (smtpgate1.pacific.net.sg [203.120.90.27]) by mx1.FreeBSD.org (Postfix) with SMTP id 0644343D45 for ; Sun, 6 Nov 2005 04:07:50 +0000 (GMT) (envelope-from oceanare@pacific.net.sg) Received: (qmail 32146 invoked from network); 6 Nov 2005 04:07:48 -0000 Received: from maxwell6.pacific.net.sg (203.120.90.212) by smtpgate1.pacific.net.sg with SMTP; 6 Nov 2005 04:07:48 -0000 Received: from [192.168.0.107] ([210.24.246.23]) by maxwell6.pacific.net.sg with ESMTP id <20051106040747.IQHH16871.maxwell6.pacific.net.sg@[192.168.0.107]>; Sun, 6 Nov 2005 12:07:47 +0800 Message-ID: <436D8181.9090909@pacific.net.sg> Date: Sun, 06 Nov 2005 12:07:29 +0800 From: Erich Dollansky Organization: oceanare pte ltd User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051008) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nicolas Blais References: <200511051927.40752.nb_root@videotron.ca> In-Reply-To: <200511051927.40752.nb_root@videotron.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2005 04:07:52 -0000 Hi, Nicolas Blais wrote: > > It compiles and works fine. I'm trying to make the same program in C++. Is > the syntax for pthreading the same as in C? I was wondering if someone can > point me in the right direction. > the threading stuff stays the same. > Also, is there anything I should be worried about when using pthread and C++? > (Some years ago, I heard that FreeBSD's pthread didn't like C++... could be a > false rumour) You cannot use classes directly with threading functions. Your classes must be aware of threading. You need some mechanism to protect classes which are not threadsafe if more than one thread could access an object at te same moment of time. This is a general problem of threading which might causes problems. Do not forget that C++ uses additional data in objects which the programmer does not see. Erich