From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43138 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8TqY-0003Ax-Ox for qemu-devel@nongnu.org; Wed, 20 Oct 2010 04:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8TqX-0008SF-JO for qemu-devel@nongnu.org; Wed, 20 Oct 2010 04:16:30 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:44805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8TqX-0008S8-F4 for qemu-devel@nongnu.org; Wed, 20 Oct 2010 04:16:29 -0400 Received: by gyb11 with SMTP id 11so1976918gyb.4 for ; Wed, 20 Oct 2010 01:16:28 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20101019174245.16514.14542.stgit@localhost6.localdomain6> References: <20101019173946.16514.62027.stgit@localhost6.localdomain6> <20101019174245.16514.14542.stgit@localhost6.localdomain6> Date: Wed, 20 Oct 2010 09:16:28 +0100 Message-ID: Subject: Re: [Qemu-devel] [PATCH 1/3] Introduce threadlets From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Arun R Bharadwaj Cc: qemu-devel@nongnu.org On Tue, Oct 19, 2010 at 6:42 PM, Arun R Bharadwaj wrote: > +/** > + * cancel_threadletwork_on_queue: Cancel a task queued on a Queue. > + * @queue: The queue containing the task to be cancelled. > + * @work: Contains the information of the task that needs to be cancelle= d. > + * > + * Returns: 0 if the task is successfully cancelled. > + * =A0 =A0 =A0 =A0 =A01 otherwise. The return value comment doesn't correspond to how I read the code. If the work was cancelled the code returns 1. Otherwise it returns 0. > + */ > +int cancel_threadletwork_on_queue(ThreadletQueue *queue, ThreadletWork *= work) > +{ > + =A0 =A0ThreadletWork *ret_work; > + =A0 =A0int ret =3D 0; > + > + =A0 =A0qemu_mutex_lock(&(queue->lock)); > + =A0 =A0QTAILQ_FOREACH(ret_work, &(queue->request_list), node) { > + =A0 =A0 =A0 =A0if (ret_work =3D=3D work) { > + =A0 =A0 =A0 =A0 =A0 =A0QTAILQ_REMOVE(&(queue->request_list), ret_work, = node); > + =A0 =A0 =A0 =A0 =A0 =A0ret =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0break; > + =A0 =A0 =A0 =A0} > + =A0 =A0} > + =A0 =A0qemu_mutex_unlock(&(queue->lock)); > + > + =A0 =A0return ret; > +} Stefan