namespace kernel {
namespace activity {
class ActivityImpl;
- }
- namespace routing {
- class NetPoint;
+XBT_PUBLIC(void) intrusive_ptr_add_ref(ActivityImpl* activity);
+XBT_PUBLIC(void) intrusive_ptr_release(ActivityImpl* activity);
+}
+namespace routing {
+class NetPoint;
}
}
namespace simix {
-/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/activity/ActivityImpl.hpp"
-simgrid::kernel::activity::ActivityImpl::ActivityImpl() = default;
-simgrid::kernel::activity::ActivityImpl::~ActivityImpl() = default;
+namespace simgrid {
+namespace kernel {
+namespace activity {
-void simgrid::kernel::activity::ActivityImpl::ref()
+ActivityImpl::ActivityImpl() = default;
+ActivityImpl::~ActivityImpl() = default;
+
+void ActivityImpl::ref()
{
// Atomic operation! Do not split in two instructions!
xbt_assert(refcount_ != 0);
refcount_++;
}
-void simgrid::kernel::activity::ActivityImpl::unref()
+void ActivityImpl::unref()
{
xbt_assert(refcount_ > 0,
"This activity has a negative refcount! You can only call test() or wait() once per activity.");
if (refcount_ == 0)
delete this;
}
+
+// boost::intrusive_ptr<Activity> support:
+void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
+{
+ activity->ref();
+}
+
+void intrusive_ptr_release(simgrid::kernel::activity::ActivityImpl* activity)
+{
+ activity->unref();
+}
+}
+}
+} // namespace simgrid::kernel::activity::
-/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
virtual void resume()=0;
virtual void post() =0; // What to do when a simcall terminates
- // boost::intrusive_ptr<Activity> support:
- friend void intrusive_ptr_add_ref(ActivityImpl * activity)
- {
- activity->ref();
- }
-
- friend void intrusive_ptr_release(ActivityImpl * activity)
- {
- activity->unref();
- }
-
/** @brief Increases the refcount */
void ref();
/** @brief Reduces the refcount */
void unref();
+ // boost::intrusive_ptr<Activity> support:
+ friend void intrusive_ptr_add_ref(ActivityImpl * activity);
+ friend void intrusive_ptr_release(ActivityImpl * activity);
private:
std::atomic_int_fast32_t refcount_{1};
#include <xbt/base.h>
#include <simgrid/simix.h>
+#include <src/kernel/activity/ActivityImpl.hpp>
+#include <src/kernel/activity/CommImpl.hpp>
+
+#include <boost/intrusive_ptr.hpp>
+
SG_BEGIN_DECL()
/********************************* Simcalls *********************************/
return static_cast<T*>(simcall.dp);
}
+template <class T>
+inline void marshal(type<boost::intrusive_ptr<T>>, u_smx_scalar& simcall, boost::intrusive_ptr<T> value)
+{
+ intrusive_ptr_add_ref(&*value);
+ simcall.dp = static_cast<void*>(&*value);
+}
+template <class T> inline boost::intrusive_ptr<T> unmarshal(type<boost::intrusive_ptr<T>>, u_smx_scalar const& simcall)
+{
+ boost::intrusive_ptr<T> res = boost::intrusive_ptr<T>(static_cast<T*>(simcall.dp), false);
+ intrusive_ptr_release(&*res);
+ return res;
+}
+
template<class R, class... T> inline
void marshal(type<R(*)(T...)>, u_smx_scalar& simcall, R(*value)(T...))
{