Embedded Multicore Building Blocks V1.0.0
action_attributes.h
1 /*
2  * Copyright (c) 2014-2017, Siemens AG. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  * POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef EMBB_MTAPI_ACTION_ATTRIBUTES_H_
28 #define EMBB_MTAPI_ACTION_ATTRIBUTES_H_
29 
30 #include <embb/mtapi/c/mtapi.h>
31 #include <embb/mtapi/internal/check_status.h>
32 #include <embb/mtapi/affinity.h>
33 
34 namespace embb {
35 namespace mtapi {
36 
43  public:
49  mtapi_status_t status;
50  mtapi_actionattr_init(&attributes_, &status);
51  internal::CheckStatus(status);
52  }
53 
62  bool state
63  ) {
64  mtapi_status_t status;
65  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
66  mtapi_actionattr_set(&attributes_, MTAPI_ACTION_GLOBAL,
67  &st, sizeof(st), &status);
68  internal::CheckStatus(status);
69  return *this;
70  }
71 
79  Affinity const & affinity
80  ) {
81  mtapi_status_t status;
82  mtapi_affinity_t af = affinity.GetInternal();
83  mtapi_actionattr_set(&attributes_, MTAPI_ACTION_AFFINITY,
84  &af, sizeof(af), &status);
85  internal::CheckStatus(status);
86  return *this;
87  }
88 
97  bool state
98  ) {
99  mtapi_status_t status;
100  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
101  mtapi_actionattr_set(&attributes_, MTAPI_ACTION_DOMAIN_SHARED,
102  &st, sizeof(st), &status);
103  internal::CheckStatus(status);
104  return *this;
105  }
106 
114  mtapi_action_attributes_t const & GetInternal() const {
115  return attributes_;
116  }
117 
118  private:
119  mtapi_action_attributes_t attributes_;
120 };
121 
122 } // namespace mtapi
123 } // namespace embb
124 
125 #endif // EMBB_MTAPI_ACTION_ATTRIBUTES_H_
ActionAttributes & SetAffinity(Affinity const &affinity)
Sets the affinity of an Action.
Definition: action_attributes.h:78
Definition: lock_free_mpmc_queue.h:40
Contains attributes of an Action.
Definition: action_attributes.h:42
ActionAttributes()
Constructs an ActionAttributes object.
Definition: action_attributes.h:48
Describes the affinity of an Action or Task to a worker thread of a Node.
Definition: affinity.h:41
mtapi_uint64_t mtapi_affinity_t
Core affinity type.
Definition: mtapi.h:350
ActionAttributes & SetDomainShared(bool state)
Sets the domain shared property of an Action.
Definition: action_attributes.h:96
mtapi_affinity_t GetInternal() const
Returns the internal representation of this object.
Definition: affinity.h:136
mtapi_action_attributes_t const & GetInternal() const
Returns the internal representation of this object.
Definition: action_attributes.h:114
ActionAttributes & SetGlobal(bool state)
Sets the global property of an Action.
Definition: action_attributes.h:61