source: src/libcfa/concurrency/monitor@ cc7f4b1

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since cc7f4b1 was cc7f4b1, checked in by Thierry Delisle <tdelisle@…>, 9 years ago
  • renamed monitor to monitor_t since the type should not be exposed to users
  • added support for recursion in monitors
  • Property mode set to 100644
File size: 1017 bytes
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"
22
[cc7f4b1]23struct __monitor_t {
[f07e037]24 spinlock lock;
[cc7f4b1]25 thread * owner;
[f07e037]26 simple_thread_list entry_queue;
[cc7f4b1]27 unsigned int recursion;
[f07e037]28};
29
[cc7f4b1]30static inline void ?{}(__monitor_t * this) {
31 this->owner = 0;
32 this->recursion = 0;
33}
34
35void enter(__monitor_t *);
36void leave(__monitor_t *);
[f07e037]37
[cc7f4b1]38struct monitor_guard_t {
39 __monitor_t * m;
[51f3798]40};
41
[cc7f4b1]42static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) {
[51f3798]43 this->m = m;
44 enter( this->m );
45}
46
[cc7f4b1]47static inline void ^?{}( monitor_guard_t * this ) {
[51f3798]48 leave( this->m );
49}
50
[f07e037]51#endif //MONITOR_H
Note: See TracBrowser for help on using the repository browser.