HClib  0.3
Documentation for Habanero-C Library API
 All Data Structures Functions Typedefs Enumerations Groups
runtime-callback.c
1 /* Copyright (c) 2013, Rice University
2 
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions are
5 met:
6 
7 1. Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above
10  copyright notice, this list of conditions and the following
11  disclaimer in the documentation and/or other materials provided
12  with the distribution.
13 3. Neither the name of Rice University
14  nor the names of its contributors may be used to endorse or
15  promote products derived from this software without specific
16  prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 */
31 
37 #include <stdio.h>
38 
39 #include "runtime-callback.h"
40 #include "runtime-hclib.h"
41 
45 inline static void async_run_start(async_task_t * async_task) {
46  // Currently nothing to do here
47 
48  // Note: not to be mistaken with the 'async'
49  // function that create the async and
50  // check in the finish scope.
51 }
52 
56 inline static void async_run_end(async_task_t * async_task) {
57  // Async has ran, checkout from its finish scope
58  async_check_out_finish(async_task);
59  #ifdef HAVE_PHASER
60  async_drop_phasers(async_task);
61  #endif
62 }
63 
68 void rtcb_check_out_finish(finish_t * finish) {
69  check_out_finish(finish);
70 }
71 
75 void rtcb_async_run(async_task_t * async_task) {
76  async_run_start(async_task);
77  // Call the targeted function with its arguments
78  async_t async_def = async_task->def;
79  ((asyncFct_t)(async_def.fct_ptr))(async_def.arg);
80  async_run_end(async_task);
81  deallocate_async_task(async_task);
82 }