(***********************************************************************) (* *) (* Applied Type System *) (* *) (* Hongwei Xi *) (* *) (***********************************************************************) (* ** ATS - Unleashing the Potential of Types! ** ** Copyright (C) 2002-2009 Hongwei Xi, Boston University ** ** All rights reserved ** ** ATS is free software; you can redistribute it and/or modify it under ** the terms of the GNU General Public License as published by the Free ** Software Foundation; either version 2.1, or (at your option) any later ** version. ** ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY ** WARRANTY; without even the implied warranty of MERCHANTABILITY or ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ** for more details. ** ** You should have received a copy of the GNU General Public License ** along with ATS; see the file COPYING. If not, write to the Free ** Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ** 02110-1301, USA. *) (* ****** ****** *) (* ** ** Contributed by Hongwei Xi (hwxi AT cs DOT bu DOT edu) ** Time: March, 2010 ** *) (* ****** ****** *) #include "../contrib/linqueuelst/linqueuelst.dats" // end of [#include] (* ****** ****** *) staload "libats/SATS/parwork.sats" (* ****** ****** *) // assume workshop = ... (* ****** ****** *) (* viewtypedef WORK (vt:viewtype) = ((vt) - void, vt) viewtypedef work = [vt:viewtype] work vt *) absviewt@ype WORK = @(ptr, ptr) (* ****** ****** *) absviewtype WORKQUE_ptr (l:addr) extern fun WORKQUE_make_null (): WORKQUE_ptr (null) extern fun WORKQUE_free_null (q: WORKQUE_ptr null): void (* ****** ****** *) absviewtype WORKQUELOCK_ptr (l:addr) (* ****** ****** *) extern fun workquelock_make (): [l:addr] WORKQUELOCK_ptr l extern fun workquelock_acquire {l1:addr} (lock: !WORKQUELOCK_ptr l1): [l2:addr] WORKQUE_ptr l2 // end of [workquelock_acquire] extern fun workquelock_release {l1:addr} {l2:anz} (lock: !WORKQUELOCK_ptr l1, q: WORKQUE_ptr l2): [l2:addr] WORKQUE_ptr l2 // end of [workquelock_release] (* ****** ****** *) extern fun workshop_add_worker (ws: !workshop): void implement workshop_add_worker (ws) = let fun doWork (ws: workshop): void = let val w = workshop_get_work () (* ****** ****** *) //// #define NWORKER 2 implement workshop_make () = let val theWQ = WORKQUE_make_null () val () = WORKQUE_free_null (theWQ) in end // end of [workshop_make] (* ****** ****** *) (* end of [parwork.dats] *)