/**
* Convenience function for executing only one object in one executor.
+ * This function calls forb_signal_server_ready() at the appropriate
+ * place.
*
* @param obj The object to execute.
*
if (ret) goto error;
ret = forb_executor_register_object(&executor, obj);
if (ret) goto destroy_and_error;
+
+ ret = forb_signal_server_ready(obj->orb);
+ if (ret) goto destroy_and_error;
ret = forb_executor_run(&executor);
#include <forb.h>
#include <string.h>
#include <forb/server_id.h>
-
+#include <semaphore.h>
/**
* Temporary directory for FORB's housekeeping.
forb_init_attr_t attr; /**< Initialization attributes */
+ sem_t server_ready; /**< Synchronize starting of multiple servers in a single address space. */
+
fosa_mutex_t request_id_mutex; /**< Mutex for request_id */
CORBA_long request_id; /**< Value of next sent request_id */
int
forb_init_tmp_dir(void);
+int
+forb_wait_for_server_ready(forb_orb orb);
+
#endif
memset(&forb->attr, 0, sizeof(forb->attr));
}
+ sem_init(&forb->server_ready, 0, 0);
+
if (forb_server_id_empty(&forb->attr.fixed_server_id)) {
forb_server_id_init(&forb->server_id);
} else {
return 0;
}
+
+/**
+ * Wait for the server to be ready. Internal function intended forb
+ * forbrun.
+ *
+ * @param orb ORB.
+ *
+ * @return Zero on success; on error -1 is returned, and errno is set
+ * to indicate the error.
+ */
+int forb_wait_for_server_ready(forb_orb orb)
+{
+ forb_t *forb = forb_object_to_forb(orb);
+ return sem_wait(&forb->server_ready);
+}
+
+/**
+ * Signal the the FORB core that the server is ready for accepting
+ * requests.
+ *
+ * This function should be called at the initialization of server
+ * implementation at the time when all objects are registered with
+ * executors. All other servers in the same address space are
+ * initialized after this function is called which allows the other
+ * servers to use the services provided by the calling server.
+ *
+ * @param orb ORB object.
+ *
+ * @return Zero on success; on error -1 is returned, and errno is set
+ * to indicate the error.
+ */
+int forb_signal_server_ready(forb_orb orb)
+{
+ forb_t *forb = forb_object_to_forb(orb);
+ return sem_post(&forb->server_ready);
+}