Beispiel #1
0
DirectResult
fusion_ref_watch (FusionRef *ref, FusionCall *call, int call_arg)
{
     DirectResult ret;

     D_ASSERT( ref != NULL );
     D_ASSERT( call != NULL );

     ret = fusion_skirmish_prevail( &ref->multi.builtin.lock );
     if (ret)
          return ret;
     
     if (ref->multi.builtin.local+ref->multi.builtin.global == 0) {
          D_BUG( "ref has no references" );
          ret = DR_BUG;
     }
     else if (ref->multi.builtin.call) {
          ret = DR_BUSY;
     }
     else {
          ref->multi.builtin.call = call;
          ref->multi.builtin.call_arg = call_arg;
          fusion_skirmish_notify( &ref->multi.builtin.lock );
     }
     
     fusion_skirmish_dismiss( &ref->multi.builtin.lock );

     return ret;
}
Beispiel #2
0
DirectResult
_fusion_ref_change (FusionRef *ref, int add, bool global)
{
     DirectResult ret;

     D_ASSERT( ref != NULL );
     D_ASSERT( add != 0 );

     ret = fusion_skirmish_prevail( &ref->multi.builtin.lock );
     if (ret)
          return ret;
     
     if (global) {
          if (ref->multi.builtin.global+add < 0) {
               D_BUG( "ref has no global references" );
               fusion_skirmish_dismiss( &ref->multi.builtin.lock );
               return DR_BUG;
          }

          ref->multi.builtin.global += add;
     }
     else {          
          if (ref->multi.builtin.local+add < 0) {
               D_BUG( "ref has no local references" );
               fusion_skirmish_dismiss( &ref->multi.builtin.lock );
               return DR_BUG;
          }

          ref->multi.builtin.local += add;
          
          _fusion_add_local( _fusion_world(ref->multi.shared), ref, add ); 
     }

     if (ref->multi.builtin.local+ref->multi.builtin.global == 0) {
          fusion_skirmish_notify( &ref->multi.builtin.lock );

          if (ref->multi.builtin.call) {
               fusion_skirmish_dismiss( &ref->multi.builtin.lock );
               return fusion_call_execute( ref->multi.builtin.call, FCEF_ONEWAY, 
                                           ref->multi.builtin.call_arg, NULL, NULL );
          }
     }
     
     fusion_skirmish_dismiss( &ref->multi.builtin.lock );

     return DR_OK;
}
Beispiel #3
0
void
dfb_core_activate( CoreDFB *core )
{
     CoreDFBShared *shared;

     D_MAGIC_ASSERT( core, CoreDFB );

     shared = core->shared;
     D_MAGIC_ASSERT( shared, CoreDFBShared );

     fusion_skirmish_prevail( &shared->lock );

     shared->active = true;

     fusion_skirmish_notify( &shared->lock );

     fusion_skirmish_dismiss( &shared->lock );
}