source: src/libcfa/concurrency/monitor @ 17af7d1

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 17af7d1 was 17af7d1, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Some clean-up of runtime code

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[f07e037]1//                              -*- Mode: CFA -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// monitor --
9//
10// Author           : Thierry Delisle
11// Created On       : Thd Feb 23 12:27:26 2017
12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count     : 0
15//
16
17#ifndef MONITOR_H
18#define MONITOR_H
19
20#include "assert"
21#include "invoke.h"
[2781e65]22#include "stdlib"
[f07e037]23
[84c52a8]24struct monitor_desc {
[f07e037]25        spinlock lock;
[348006f]26        thread_desc * owner;
[f07e037]27        simple_thread_list entry_queue;
[cc7f4b1]28        unsigned int recursion;
[f07e037]29};
30
[84c52a8]31static inline void ?{}(monitor_desc * this) {
[cc7f4b1]32        this->owner = 0;
33        this->recursion = 0;
34}
35
[2781e65]36//Array entering routine
[84c52a8]37void enter(monitor_desc **, int count);
38void leave(monitor_desc **, int count);
[2781e65]39
[cc7f4b1]40struct monitor_guard_t {
[84c52a8]41        monitor_desc ** m;
[2781e65]42        int count;
[51f3798]43};
44
[84c52a8]45static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) {
[2781e65]46        return ((intptr_t)lhs) < ((intptr_t)rhs);
47}
48
[84c52a8]49static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) {
[2781e65]50        this->m = m;
51        this->count = count;
52        qsort(this->m, count);
53        enter( this->m, this->count );
[51f3798]54}
55
[cc7f4b1]56static inline void ^?{}( monitor_guard_t * this ) {
[2781e65]57        leave( this->m, this->count );
[51f3798]58}
59
[2781e65]60
[f07e037]61#endif //MONITOR_H
Note: See TracBrowser for help on using the repository browser.