Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-reentrant.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
43 typedef struct sol_reentrant {
47  bool in_use;
51  bool delete_me;
53 
78 #define SOL_REENTRANT_CALL(handle) \
79  for (bool reentrant_run = true; reentrant_run; reentrant_run = false) \
80  for (bool reentrant_was_used = (handle).in_use; reentrant_run; \
81  (handle).in_use = reentrant_was_used, reentrant_run = false) \
82  for ((handle).in_use = true; reentrant_run; reentrant_run = false)
83 
93 #define SOL_REENTRANT_FREE(reentrant) \
94  if (({ (reentrant).delete_me = true; !(reentrant).in_use; }))
95 
100 #ifdef __cplusplus
101 }
102 #endif
Structure containing the flags for safely freeing a larger structure.
Definition: sol-reentrant.h:43
bool delete_me
Structure is stale and should be freed as soon as possible.
Definition: sol-reentrant.h:51
struct sol_reentrant sol_reentrant
Structure containing the flags for safely freeing a larger structure.
bool in_use
Structure is in use.
Definition: sol-reentrant.h:47