LCOV - code coverage report
Current view: directory - js/src/shell - jsworkers.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2012-06-02 Functions: 3 2 66.7 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: set ts=8 sw=4 et tw=99:
       3                 :  *
       4                 :  * ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is JavaScript shell workers.
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  * Mozilla Corporation.
      21                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *   Jason Orendorff <jorendorff@mozilla.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #ifndef jsworkers_h___
      42                 : #define jsworkers_h___
      43                 : 
      44                 : #ifdef JS_THREADSAFE
      45                 : 
      46                 : #include "jsapi.h"
      47                 : 
      48                 : /*
      49                 :  * Workers for the JS shell.
      50                 :  *
      51                 :  * Note: The real implementation of DOM Workers is in dom/workers.
      52                 :  */
      53                 : namespace js {
      54                 :     namespace workers {
      55                 :         class ThreadPool;
      56                 : 
      57           18405 :         class WorkerHooks {
      58                 :         public:
      59                 :             virtual JSObject *newGlobalObject(JSContext *cx) = 0;
      60           18405 :             virtual ~WorkerHooks() {}
      61                 :         };
      62                 : 
      63                 :         /*
      64                 :          * Initialize workers. This defines the Worker constructor on global.
      65                 :          * Requires request. rootp must point to a GC root.
      66                 :          *
      67                 :          * On success, *rootp receives a pointer to an object, and init returns
      68                 :          * a non-null value. The caller must keep the object rooted and must
      69                 :          * pass it to js::workers::finish later.
      70                 :          */
      71                 :         ThreadPool *init(JSContext *cx, WorkerHooks *hooks, JSObject *global, JSObject **rootp);
      72                 : 
      73                 :         /* Asynchronously signal for all workers to terminate.
      74                 :          *
      75                 :          * Call this before calling finish() to shut down without waiting for
      76                 :          * all messages to be proceesed.
      77                 :          */
      78                 :         void terminateAll(ThreadPool *tp);
      79                 : 
      80                 :         /*
      81                 :          * Finish running any workers, shut down the thread pool, and free all
      82                 :          * resources associated with workers. The application must call this
      83                 :          * before shutting down the runtime, and not during GC.
      84                 :          *
      85                 :          * Requires request.
      86                 :          */
      87                 :         void finish(JSContext *cx, ThreadPool *tp);
      88                 :     }
      89                 : }
      90                 : 
      91                 : #endif /* JS_THREADSAFE */
      92                 : 
      93                 : #endif /* jsworkers_h___ */

Generated by: LCOV version 1.7